-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ImageMedium#derivatives now works with image filters (#1107)
* ImageMedium->derivatives now works with image filters Previously, using ImageMedium->derivatives would not work well in combination with image filters or the other method of generating srcset variants of images (by appending eg. "@2x" to their filenames). This commit hopefully fixes that. * Modified initialization of image alternatives The biggest alternative will now become the base medium, and alternatives will be filled out as necessary in a descending manner. * Fully reset image when derivatives method is called Otherwise we get some funky results, with the possibility of two different images being rendered between the full-width srcset version and the original src version. * Account for risk of original file not existing when generating image derivatives * Fixed an issue where too many alternatives would be generated When using naming conventions to generate image alternatives, this patch would previously generate a “@1x” alternative if one didn’t exist. That’s no longer the case * Add an "@1x" alternative when an image lacks a base medium When an image only has an alternative medium - ie. the only version of the image ends in eg. "@3x", then we construct the missing alternatives automatically. Previously, we would only do this down till "@2x", meaning that the image that would have been the base medium, had the image been manually resized, wasn't created. This has now been fixed. * Always make smallest image alternative the base medium When an image lacks a base medium on disk (eg. the only existing image is an @2x version), then we make a scaled down version the base medium, which ensures that the smaller version is served up in the src attribute in the HTML. Also, don't reset the image alternatives when calling ImageMedium#derivatives, instead only generate the image alternatives that are missing. * Set better prettynames for image derivatives * Changed image derivatives prettynames to be width based Instead of example2x.jpeg, we now have eg. example1280w.jpeg
- Loading branch information
1 parent
a96820a
commit db4c9c1
Showing
4 changed files
with
69 additions
and
56 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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