@deliciousbrains thanks once again for the quick response. Here’s the answers to all your questions:
0. I’m assuming the custom code is in the “REDUCTED” plugin, but if not, where is it?
I would greatly appreciate @deliciousbrains if you can edit your comment to hide the plugin name due to privacy concerns. But yes the code is in a plugin.
1. Upload the test mp4 to the Media Library via the standard UI to check that it offloads as expected.
This works, and I tested it again just now to re-confirm. I tested both the WP-ADMIN media page as well as front-end ACF controls – manually uploading files to media library works without issue.
2. Disable EWWW Image Optimizer and try uploading the test mp4 via the custom code.
After the manual tests at 1. I did a test before disabling EWWW for error log purposes. The video didn’t get uploaded to S3 (it stayed with a local URL).
After disabling EWWW the video uploaded to S3 and has a CDN domain URL!!! So this seems indicative that it is an issue with combining EWWW and Offload Media plugins.
3. Try uploading a test png via the custom code.
This always works but there is a slight issue I’ve noticed with PNG files that are on S3 – such that sometimes the wp_get_attachment_image_url and similar functions may return the local file URL which doesn’t work – resulting in broken images. Again no PHP or other errors with this and it only happens when uploading multiple images via code one after the other in short amount of time. Calling the function to get the URL again results in the correct URL. So I deduced this is a timing issue with something but it could be that it is again related to EWWW – this would be much harder to test since it’s not always happening. Regardless that’s why I now I do a find-replace on the URL for images. In my case this is something I can afford to do since I then store the URL and IMG tag in metadata (due to the nature of our system which I won’t go too much into) so it’s not something I do every time I display the image on the front end haha.
4. You mentioned nothing found in wp-content/debug.log, but your diagnostics say that debug errors go to logs/php-error.log, please check that after running your tests.
Yes I was already monitoring the php-error.log too, and during this whole ordeal there was never a PHP error related to this issue we’re discussing, in fact during the tests today there was no PHP error or warning whatsoever.
5. Please also confirm when the upload_from_url
function is run. Is it triggered from a manual admin UI function called by a user that’s entered a URL, or something automatic, e.g. cron?
It is triggered on a webhook endpoint being called, so automatic/cron-like (not a manual action).
FINALLY I am at your disposal if you want me to test some other things for your convenience. I presume you are the author of the plugin and as such since EWWW is quite a popular plugin too I would assume you might want to try and improve compatibility between the two. For me for now I can continue without using EWWW until such a time this issue is resolved.
My 2 cents would be that maybe it’s an issue with timing, since videos probably take longer to process and then additionally be processed by EWWW – so maybe you could be checking whether EWWW is present and if so use a hook from EWWW for checking whether media finished uploading/registering in the media library instead of using the default WP hooks? I am sorry if I am overstepping and suggesting stupid ideas hahah.
I will not mark this resolved for the time being, will wait on your response and thoughts.
But thank you very much! I can’t believe I didn’t think to try without EWWW in my mind it didn’t make sense to not work with the popular image optimization plugins…