-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow controlling which image format sources in the frontend can be replaced #238
Comments
I think we can reuse the existing More concretely, I'm suggesting the following approach to make the sources for the replacement more dynamic:
The above would mean that for the current default filter value
See the Let me know your thoughts on the above. I think it would be a simple and reliable solution to allow control over which formats to potentially replace. While it would technically also enable doing "odd" things like replacing PNG with JPEG, the eventual replacement still always depends on which formats exist for the attachment, so it wouldn't realistically happen - unless a developer added support for generating JPEG from PNG image uploads (which may not even be a bad idea!). |
@felixarntz, just want to re-iterate my thoughts that we discussed yesterday. Do we really need to check format of the original image? If we have a replacement for it in a modern format that has a smaller size, then we can replace the image without checking its format/extension. If there is no an alternative size for an image, then we shouldn't touch it and leave as is. Does it make sense to you? |
@eugene-manuilov Double-checking, this would mean we would no longer rely on It may not work for certain plugins that e.g. integrate with a CDN and also modify frontend URLs on the fly, but I like your approach here, specifically because it actually feels safer. This way we only replace data based on the original attachment metadata, and if that is for some reason not what's used in the content, at least we're not breaking anything. Feel free to open a PR with your proposed approach, I think that sounds solid. The main achievement here needs to be that we don't have it hard-coded to just JPEGs. |
@felixarntz, I have prepared #262, do you mind looking at it? As to the CDN, I don't think it will be an issue. Changes in my PR don't modify the whole URL, we just replace the filename itself. So CDN URLs should continue working. |
Fixed via #262. |
Follow-up to #187: The
webp_uploads_content_image_mimes
currently controls which image formats can be used as replacements in the frontend. However, the formats that can currently be replaced in the frontend are still hard-coded - at the moment it is just JPEG (specifically its extensionsjpg
andjpeg
).We need to implement a way so that these source image formats can also be controlled through a filter. For example, if somebody implemented support to create WebP versions for PNG uploads, it should be possible to use the WebP Uploads module's logic to replace PNGs as well.
Related is #237, however let's keep these two decoupled. Depending on the decision in #237, it may simply be that the expected order of the filtered items changes, which would be trivial to update here.
The text was updated successfully, but these errors were encountered: