Fix ico format conversion to work in template

pull/12028/head
Julie Rymer 2024-06-07 19:11:03 +02:00 zatwierdzone przez Jake Howard
rodzic ebc77dda83
commit f5552c4044
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 8198AEBFA7E86782
6 zmienionych plików z 18 dodań i 1 usunięć

Wyświetl plik

@ -18,6 +18,7 @@ Changelog
* Fix: Support SVG icon id attributes with single quotes in the styleguide (Sage Abdullah)
* Fix: Do not show delete button on model edit views if per-instance permissions prevent deletion (Matt Westcott)
* Fix: Remove duplicate header in privacy dialog when a privacy setting is set on a parent page or collection (Matthias Brück)
* Fix: Allow renditions of `.ico` images (Julie Rymer)
* Docs: Remove duplicate section on frontend caching proxies from performance page (Jake Howard)
* Docs: Document `restriction_type` field on PageViewRestriction (Shlomo Markowitz)
* Docs: Document Wagtail's bug bounty policy (Jake Howard)

Wyświetl plik

@ -818,6 +818,7 @@
* Saksham Misra
* Nigel van Keulen
* Matthias Brück
* Julie Rymer
## Translators

Wyświetl plik

@ -32,6 +32,7 @@ depth: 1
* Support SVG icon id attributes with single quotes in the styleguide (Sage Abdullah)
* Do not show delete button on model edit views if per-instance permissions prevent deletion (Matt Westcott)
* Remove duplicate header in privacy dialog when a privacy setting is set on a parent page or collection (Matthias Brück)
* Allow renditions of `.ico` images (Julie Rymer)
### Documentation

Wyświetl plik

@ -449,7 +449,8 @@ You can encode the image into lossless AVIF or WebP format by using `format-avif
You can save images as a `.ico` file using `format-ico`, which is especially useful when managing a site's favicon through the Admin.
```html+django
<link rel="icon" href="{% image favicon_image format-ico %}" />
{% image favicon_image format-ico as favicon_image_formatted %}
<link rel="icon" type="image/x-icon" href="{{ favicon_image_formatted.url }}"/>
```
(image_background_colour)=

Wyświetl plik

@ -59,6 +59,7 @@ IMAGE_FORMAT_EXTENSIONS = {
"gif": ".gif",
"webp": ".webp",
"svg": ".svg",
"ico": ".ico",
}

Wyświetl plik

@ -1,4 +1,5 @@
from io import BytesIO
from pathlib import Path
from unittest.mock import patch
from django.test import TestCase, override_settings
@ -11,6 +12,7 @@ from wagtail.images.exceptions import (
)
from wagtail.images.image_operations import TransformOperation
from wagtail.images.models import Filter, Image
from wagtail.images.shortcuts import get_rendition_or_not_found
from wagtail.images.tests.utils import (
get_test_image_file,
get_test_image_file_avif,
@ -693,6 +695,16 @@ class TestFormatFilter(TestCase):
self.assertEqual(out.format_name, "ico")
def test_ico_rendition(self):
fil = Filter(spec="width-400|format-ico")
good_image = Image.objects.create(
title="Test image",
file=get_test_image_file(),
)
rendition = get_rendition_or_not_found(good_image, fil)
self.assertEqual(Path(rendition.file.name).suffix, ".ico")
def test_webp_lossless(self):
fil = Filter(spec="width-400|format-webp-lossless")
image = Image.objects.create(