-
Notifications
You must be signed in to change notification settings - Fork 27
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
Apply nginx rules for next gen images #824
Conversation
classes/Webp/RewriteRules/Nginx.php
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we update the value of the class const TAG_NAME
to be generic?
Don't we also need to move it out of the Webp namespace?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree it feels weird to do it like this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mentioned that in the PR description (risks part) but let me explain this in details, the idea here is, currently our customers have old webp rules and if I understand this part well, we are detecting those rules by this tag name, so if I changed this tag name without adding an update routine to completely remove the old rules, we will end up having two rules, something like the following:
# BEGIN Imagify: rewrite rules for webp
OLD RULES
# END Imagify: rewrite rules for webp
# BEGIN Imagify: rewrite rules for nextgen
NEW RULES
# END Imagify: rewrite rules for nextgen
but if we kept it as webp we will not need this update routine.
If u think that would be confusing/weird we can have this update routine.
classes/Avif/RewriteRules/Nginx.php
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we still keep this class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I already mentioned this also in the PR description :D
to keep the structure consistent, I kept it.
But let's think about this together.
inc/functions/attachments.php
Outdated
@@ -19,6 +19,7 @@ function imagify_get_mime_types( $type = null ) { | |||
'png' => 'image/png', | |||
'gif' => 'image/gif', | |||
'webp' => 'image/webp', | |||
'avif' => 'image/avif', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should not be added, it's causing bugs in some cases (we already reverted it in a previous PR)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many thanks, going to remove it then, wasn't aware of this previous PR.
classes/Webp/RewriteRules/Nginx.php
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree it feels weird to do it like this
Rules applied correctly on apache, local and imagify.rocketlabs. Note: on https://imagify.rocketlabsqa.ovh/ if we uploaded the zip file of any plugin, we will have error in media library (may needs further investigations when documenting changes needed at nginx server) => without playing with nginx rules at newer.rocketlabsqs upload plugin zip is fine |
Description
Fixes #821
Documentation
User documentation
Here we are playing with rewrite rules so users need to reload their nginx after upload to get those new rules being applied.
Technical documentation
Here I used the webp class to write the next gen handling rewrite rules so we don't need to run any code with plugin update to remove the old rules and insert the new ones, as I think those webp rules were already there in previous versions.
Also I kept avif rewrite rules empty to unify the code structure and keep it as currently used, but it's not added to the config file at all because it's empty.
If you think this would be confusing having the comment
Imagify: rewrite rules for webp
let me know and I can check how to do this upgrade routine here in imagify.Type of change
Delete options that are not relevant.
New dependencies
List any new dependencies that are required for this change.
Risks
List possible performance & security issues or risks, and explain how they have been mitigated.
As mentioned above we have two risks:
Imagify: rewrite rules for webp
but it's handling webp and avif.What do u think @piotrbak ?
Checklists
Feature validation
Documentation
Code style
Observability
Risks