Site logo

Archived topic

GenerateBlocks won't update background-image url after domain change

20 replies · Started by Dominik on November 16, 2020

Viewing posts 1–15 of 21

Hi,

the URLs from images, embedded as background-images in a GenerateBlocks container, won't update after a domain change. I encountered this problem twice with two different sites running on GeneratePress & GenerateBlocks. It occurs when I am transferring a website or just change the domain.

I also changed all database entries with plugins like "Better Search Replace". All other pictures and the rest of the site worked fine. Only the background images are stuck to the old URL.
A workaround is to open the page editor for each page and press the update button. This works for small sites but with larger ones it might be a lot of work.

Is there a fix for this?

thx
Manuel

Hi Manuel,

Can you specify which tables did you do a better search replace?

GB's code will appear like this on posts' contents within the database under wp_posts table.

<!-- wp:generateblocks/container {"uniqueId":"8efe5669","bgImage":{"id":169,"image":{"url":"http://elvin.wppluginsupport.net/wp-content/uploads/2020/11/d7c12733-5eb6-378a-96f0-40ea88e17650.jpg","height":746,"width":1120,"orientation":"landscape"}}} -->
<div class="gb-container gb-container-8efe5669"><div class="gb-inside-container"></div></div>
<!-- /wp:generateblocks/container -->

Say for this example, we want to replace http://elvin.wppluginsupport.net with http://www.yoursite.net.

We'll have to do a better search and replace or these 2 strings on the wp_posts table.

Hi Elvin,

I have selected all tables available and tried replacing many different string variations.

https://www.domain.com
www.domain.com
//www.domain.com
/www.domain.com
etc.

The structure of the page is very simple.

HTML

<div class="gb-container gb-container-d635c43a">
<div class="gb-inside-container"></div>
</div>

CSS

gb-container.gb-container-d635c43a {
    background-image: url(//www.domain.com/picture.jpg);
    background-repeat: no-repeat;
    background-position: center center;
    background-size: cover;
}

That's strange - these are just simple strings in your content. Plugins should be able to replace them quite easily.

Any chance you can link us to one of the pages?

Sure, find the link in the private section. We already manually updated the URLs with hitting the update button on each page again. On this subpage the hero image was the problem. All other pictures worked fine from the beginning.

Ah, I see the issue.

The CSS for each page is built as a static CSS file so it can be cached.

Changing the URLs worked, but the CSS was still cached using the old URLs.

When this happens, simply go to "Settings > GenerateBlocks" and hit the Regenerate CSS Files button - this will automatically rebuild the CSS files for you so you don't have to manually re-save each page.

Thanks for the hint and your help :). For me it looks a lot like that's the solution and I will try it next time.

No problem! :)

I run into the same (and I am looking for an automated solution)..

Is it also a 'clean solution' to 'search-and-replace' the URLs directly into the static CSS-Files? Say on the commandline with:

sed 's/old-domain/new-domain/g' /wp-content/uploads/generateblocks/*.css

after a:

wp search-replace 'old-domain' 'new-domain' --report-changed-only

Or does generatepress itself support wp-cli?
Thank you for any comments on my topic,

Ingo Baab

I have replaced the image url but the image didn't change.

Caching?

wp cache flush

I have cleared cache but nothing changes

Hi there,

can you raise a new topic where you can share a link to your site and we can take a look.

Is there a way to avoid having to do this?

I've pulled my hair out trying to find out why I couldn't get my images to show up after I moved from production to the live site.

Search replace with a plugin
Search/replace in the database

Cloning the site to another subdomain and then back to the live site... ONly to find that I have to go to GenerateBlocks and regenerate the CSS??

Whewwwwwww.... How can I avoid that because wow.

This archived topic is closed to new replies.