Skip to content

Add svg blog demo#646

Open
ankit02327 wants to merge 2 commits intowagtail:mainfrom
ankit02327:add-svg-blog-demo
Open

Add svg blog demo#646
ankit02327 wants to merge 2 commits intowagtail:mainfrom
ankit02327:add-svg-blog-demo

Conversation

@ankit02327
Copy link
Contributor

Add SVG demo usage and update rendering (fixes #602)

This PR adds SVG images to the Bakerydemo content and updates the rendering template so they display correctly.

Context

In #602 it was noted that when implementing SVG support earlier, the demo site ended up without any SVG images in its content. As a result, Bakerydemo could not be used to properly test or demonstrate Wagtail’s SVG support.

The issue requested adding one or two SVG images to the demo site for testing purposes.

More recently in #630, SVG files were added to the repository. The remaining step mentioned by @thibaudcolas was to actually use those images within the site content and ensure rendering works correctly.

Changes

1. Add SVG demo images to fixtures

Adds two SVG images to the demo fixtures:

  • chef_illustration.svg
  • sliced_bread_loaf.svg

2. Use an SVG image in demo content

Adds the sliced bread illustration to an existing blog page via the image_block so the demo site contains a visible SVG example.

3. Update template rendering for SVG

The captioned_image_block template previously rendered all images with:

{% picture self.image format-{avif,webp,jpeg} fill-{400x220,600x338} %}

This assumes raster images and performs format conversion, which is not supported for SVG images. When an SVG is used this causes:

InvalidFilterSpecError: format-* operations are not supported for SVG images

The template now detects SVG images and renders them using:

{% image self.image preserve-svg %}

while keeping the existing responsive picture pipeline for raster images.

Result

  • Bakerydemo now includes SVG images in its demo content.
  • SVG images render correctly in the site.
  • Raster images continue using responsive renditions.
image image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SVG demo image(s)

1 participant