fix: handle SVG and non-image resources in image helper and tile template#1276
Open
delize wants to merge 1 commit intoCaiJimmy:masterfrom
Open
fix: handle SVG and non-image resources in image helper and tile template#1276delize wants to merge 1 commit intoCaiJimmy:masterfrom
delize wants to merge 1 commit intoCaiJimmy:masterfrom
Conversation
…late The `helper/image` partial calls `.Height` and `.Width` on any resource returned by `.Resources.Get`, but these methods are only available on raster image resources. Non-image resources (e.g. PDFs in page bundles) cause a build error: "this method is only available for image resources". Similarly, `article-list/tile.html` calls `.Colors` on any image resource, but `.Colors` is not available on SVG resources, causing: "this method is only available for raster images". Changes: - `helper/image.html`: Add `isImage` media type check so non-image resources (PDFs, text files, etc.) get nil Height/Width like SVGs - `article-list/tile.html`: Skip `.Colors` call for SVG resources
Contributor
Author
|
Trying to upload the last minor fixes/features I have for things against v4 so I can clean up my own partials layout. Feel free to decline if desired. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
helper/image.html:.Resources.Getcan return non-image resources (e.g. PDFs, text files in page bundles). Calling.Height/.Widthon these causes a build error:this method is only available for image resources. Added anisImagemedia type check so non-image resources getnilHeight/Width, same as SVGs.article-list/tile.html:.Colorsis called on any image resource, but it's not available on SVGs, causing:this method is only available for raster images. Added an SVG subtype check before the.Colorscall.How to reproduce
imagefront matter field, or use an SVG as a featured imagehugo buildTest plan