App for Cloudflare® Pro

App for Cloudflare® Pro 1.8.9

Plugin support

modeltourism

New member
Hi,

Any potential for supporting ShortPixel with your plugin? Currently, if we upload a photo it bypasses ShortPixel and goes straight to R2 :D

Additionally, when we move media from WP to R2, it does find all the .jpg files as listed in the WP database, but it doesn't take any of the .webp images that ShortPixel makes.. :(
 
Would need to go digging on ShortPixel's code to say for certain on anything... While it's not out of the question, if they are bypassing WordPress functionality (like not using WordPress's normal system for tracking media variations), not sure it could really be done.

Again, would need to go digging before I can say definitively, but it definitely makes me curious about why they are choosing to not use the native WordPress mechanism for doing exactly what they are doing (creating variations of images).
 
Let us know if we can help in any way with this - at the moment, we've had to turn off the R2 part of your plugin - that said, the work you've done is excellent in the plugin with the other features too (we do know our way around CF already to be fair, but nice to have it in the WP dashboard for minor changes!) - so happy to have paid to support you :)
 
Let us know if we can help in any way with this - at the moment, we've had to turn off the R2 part of your plugin - that said, the work you've done is excellent in the plugin with the other features too (we do know our way around CF already to be fair, but nice to have it in the WP dashboard for minor changes!) - so happy to have paid to support you :)
Haven't installed it yet, but already skimming their code to see if anything obvious pops out at me. As I mentioned already, it does strike me as odd that they would be not using the mechanism that WordPress gives you to manage image variations because it's literally what it's there for (and in every installation of WordPress since it's part of WordPress core).

Hopefully I can figure out why they went that route and come up with a solution.
 
Out of interest, how do you determine what order things happen in? Ie, do you pause after an upload to see if any other WP plugin wants to do something with an image before you move it to R2? Just wondered how plugins are given priority to those functions!
 
In this case, you can set a specific execution order number for WordPress filters. In *theory* things should be designed so multiple plugins using the same WordPress hook aren't affected by execution order. In practice it's definitely problematic because you have no way of controlling another plugin's execution order value. You can set it very high if you want it to execute later, but it's still not always going to execute last because another plugin might also want to execute last and simply picked a higher arbitrary number. And then you have the issue where maybe you want to execute early because of ThirdPartyPluginA, but also somehow execute late at the same time because of ThirdPartyPluginB.

In this particular case, App for Cloudflare and ShortPixel are doing their "heavy lifting" within the same WordPress hook (which makes sense because both are dealing with incoming images being uploaded). Both plugins are using WordPress' default execution order, which also makes sense because as mentioned above, forcing a plugin to the end of the execution order might cause other problems (fixing one problem that causes another is never good).

ShortPixel is a lot of code to get through, and it does look like they have a lot of filters/hooks we could utilize, so I'm hopeful I can make it work regardless of execution order.

Honestly, internally WordPress core is a mess and plugin developers are still able to make things work somehow (usually). WordPress core could be designed in a way where plugin developers don't need to create one-off code to support every specific plugin they want to be compatible with. Unfortunately that's how WordPress core more or less works because it's a ton of code from PHP versions 20 years ago.
 
Been monkeying around with it, and so far I can kind of make it work, but it requires breaking some safety checks that ShortPixel has in place. Specifically I can force it so ShortPixel is tricked into thinking the files exist, but it uses that to do other things. For example, it uses the same check to verify that an image conversion worked as expected and if it did, delete the original images. The issue there is if their image conversion failed (for whatever reason), we just tricked it into thinking it worked and it deletes the original image.

Honestly, I don't particularly love the fact that I need to break their file checks that they also use to make sure things worked on their end. It feels a little like trying to fix a car with duct tape. Ya, it kind of will work... until it doesn't.

Just out of curiosity, are there specific features you are using ShortPixel for? I ran into something similar for another user where they just were trying to convert incoming images to WebP (I forget which plugin they were using), and it ended up just being easier to add that feature than it was trying to force things to work with that particular plugin.

It's still not out of the question, but in order to do it "right", probably going to require a little cooperation from ShortPixel devs.
 
Back
Top