404 when offloading media to S3

Hi,

According to this https://theme.co/apex/forum/t/release-notes-pro-2-0-x-6-0-cornerstone-3-0/24864 offloading to S3 should work with Pro.
However, after I offloaded the images to S3 then removed them from my server images disappeared, trying to load from the local server instead of S3: http://prntscr.com/mqz3bl

What can we do to make this work?

Hi There @carinaa

Thanks for writing in! Upon checking your plugin settings, I see that you’re getting some errors as well (see secure note below).

Could you please follow this guide and make sure to setup correctly (https://kinsta.com/knowledgebase/wordpress-amazon-s3/).

Also make sure to clear full cache before testing, by following this guide (https://www.wpbeginner.com/beginners-guide/how-to-clear-your-cache-in-wordpress/).

Let us know how it goes.
Thanks!

Yes, it is setup correctly.
I’ve been in touch with the Offload media plugin developers directly.
Now 100% of the images are offloaded: http://prntscr.com/mr9j4l
Those errors weren’t even related to images loaded by Pro Theme.

Take the header logo for example: Cornerstone tries to load https://visitlocaly.kinsta.com/wp-content/uploads/2019/02/VisitBo_hovedlogo_A_RGB_org.png but if you look in the media library you’ll find that the correct url for this file is https://s3-eu-west-2.amazonaws.com/visitlocally-whitelabel/wp-content/uploads/2019/02/27172114/VisitBo_hovedlogo_A_RGB_org.png

If I copy the file back to my server it works, obviously. I need the images displayed with Cornerstone to use the offloaded URLs

Clearing the cache doesn’t make any difference.

Hello @Carinaa,

Thanks for updating in! Since the images in the Cornerstone built pages were added in the page before you off loaded the image to S3, you will have to edit the urls of the images instead. Simply install Better Search and Replace plugin. You will search for https://visitlocaly.kinsta.com/wp-content/uploads/ and replace it with the new S3 location https://s3-eu-west-2.amazonaws.com/visitlocally-whitelabel/wp-content/uploads/

We would loved to know if this has work for you. Thank you.

Hi,

Thank you for the solution. It works.

However, I’ve discussed this with the Offload Media plugin developer and here is what he said:

"We don’t recommend running a search replace if it is avoidable, instead we recommend using the filters we provide to automatically rewrite the content. We don’t save the S3 version of the URLs to the database, and rewrite the URLs on the fly to the S3 URLs.

Since they mention in the changelog that they apply the filters to the saved content, I wonder if something might not be working there."

That makes sense. If we are changing domains or buckets we will have to do a search and replace again which isn’t ideal if there are filters to do this automatically.

Hello Carina,

They mentioned that they provide a filter for this. Did they mention what is the code that must be added to achieve it? If they provide the code which should be inserted in the functions.php file of the child theme, then it should be fine if that is what they recommend than using the Better Search Replace plugin.

The filter it’s for the theme developers to integrate with their theme.
He look at your theme and said it was fine but I was till experiencing issues. Headers, Footers, Global Blocks don’t update to amazon links after media was uploaded.

I sent the plugin developer steps to replicate the issue, to see if he finds out what’s wrong.

I want to keep this thread open until we have a solution.

I’m back with feedback from the offload media plugin developer.
Since Feb '18 you added support for this plugin, formerly known as Offload S3: https://theme.co/apex/forum/t/release-notes-pro-2-0-x-6-0-cornerstone-3-0/24864

However, I’ve been having troubles with making it work correctly so I reached to the plugin developer and this is his answer:

I dug into this a bit further and it appears that while the correct filters are called, they are called before WP Offload Media is loaded. This won’t work because the content is displayed before WP Offload Media gets a chance to filter the image URLs.
You may want to reach out to the theme developer and see if they can decrease the load priority of the Offload Media integration they have in order for it to work.

Here is how I was able to replicate this issue:
I turn all offload media options off.
I delete all images from media library.
I update the footer with a random image.
I go back to Offload media and enable all options except CNAME.
I start offloading.
Footer still links to local file.

I shared login information to the staging area so you can test it out.

Is it possible to provide a fix that I can add in my functions.php until it’s fully released?
Thank you.

Hi,

This will require editing Cornerstone Integration offload s3 which is part of the plugin core files.

I will forward this to our web development team for review.

Thanks

Hi,

How long do you think fixing this would take?

Hey @Carinaa,

I will follow up our developers and let them respond to this thread shortly.

Thanks.

I’m having a similar issue with the Offload S3 plugin. I did a sequential update to see where the problem lies, and it is somewhere in the X theme files, not Cornerstone. This only happened after the update to the latest version of X Theme on several of my client sites. I updated Cornerstone only and everything was still fine …but when I updated X Theme afterward, the issue appeared. The only affected image I’ve noticed is the header logo. Does the header logo load at a different priority than other images??

Hey @geekgoddess,

Though similar, your case is different because the issue here is only related to the header, footer and content builders which we’ve added an Offload S3 integration to.

X only gets the image URL for the header logo in the WordPress’ options table. I believe the Offload S3 plugin changes the URLs in that table. I’m not exactly sure so please confirm this or ask the Offload S3 support if they have such a feature. If they do, please ask them why the header logo URL’s not updated. Specifically, the option_name of the header logo is x_logo.

You can also follow Ruenel’s suggestion to run a search and replace.

Thanks.

Hi Christian, I’ve seen this happen on several client sites. Only affects the header logo. I’ve already opened up a support thread with the plugin author over on WordPress.org…but they offer limited support. It’s just so odd that it happened after the X Theme update and was fine before. In fact, the latest version of the plugin worked fine until X Theme was updated. Cornerstone updated and it was still fine. Nothing went awry until I updated the theme itself to the latest version. Then it happened every time (lost the header logo). Deleting and re-adding the image didn’t make any difference. There MUST be something different in X Theme’s codebase for this update that is overriding the filters Offload S3 has in place. I’ll pass on what you mentioned in terms of where the image URL is located.

Hi @geekgoddess,

Thank you for the information. This is something that our dev guys need to tackle and make sure it will work. Most probably the problem is the priority of the hook that was given in the previous answers. The problem is that we do not have the plugin or the setup at hand to do the test.

So if it is possible for you, we will appreciate you help us on this matter and provide us with the information below on one of your websites that has the problem to test. As you are not the original poster of this thread, you can not add the Secure note as it will be visible to the original poster. I suggest that you open up a new thread and give us the detailed steps that we need to take to recreate the logo issue alongside with the information below in a Secure Note:

  • WordPress Dashboard URL
  • WordPress Dashboard Username
  • WordPress Dashboard Password
  • FTP Server URL
  • FTP Port
  • FTP Username
  • FTP Password

Thank you.

Hi guys,

Any news on my issue?

Hi @carinaa,

No news yet, rest assured this have been added already in our issue tracker and will be dealt soon.

Kindly monitor our changelog to check if the fix has been implemented

https://theme.co/changelog/

Thanks

I have opened a new thread here so I could do a private note: https://theme.co/apex/forum/t/header-logo-broken-when-using-offload-s3/54912

Sure, let’s discuss it there. Thanks!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.