Tagged: Images, update url
-
AuthorPosts
-
December 2, 2015 at 5:19 pm #545975
We build sites on a subdomain and then when they go live we map the domain and I run a search/replace to update the URLs to the new domain. This worked for all links except for images.
I know it is all serialized, and I used Better Search Replace to do the replacing.
What is different about how images are handled?
December 3, 2015 at 6:33 am #546253Hey thatryan,
I’m not sure how that works to be honest, but you could try a plugin like this for migrating instead to see if that works better for you: WP Migrate DB https://wordpress.org/plugins/wp-migrate-db/
Regards,
RikardDecember 3, 2015 at 6:47 am #546254Thanks, I considered that plugin yeah, but not sure how it would help if I am not migrating anywhere…
December 3, 2015 at 7:34 am #546263Hey!
Best option is to use a MySQL Query for such things, so you can be sure and secured.
/* Begin Here */ UPDATE wp_posts SET guid = replace(guid, 'http://olddomain.com','http://newdomain.com'); UPDATE wp_posts SET post_content = replace(post_content, 'http://olddomain.com', 'http://newdomain.com'); UPDATE wp_links SET link_url = replace(link_url, 'http://olddomain.com', 'http://newdomain.com'); UPDATE wp_links SET link_image = replace(link_image, 'http://olddomain.com', 'http://newdomain.com'); UPDATE wp_postmeta SET meta_value = replace(meta_value, 'http://olddomain.com', 'http://newdomain.com'); UPDATE wp_usermeta SET meta_value = replace(meta_value, 'http://olddomain.com', 'http://newdomain.com'); /*UPDATE wp_options SET option_value = replace(option_value, 'http://olddomain.com', 'http://newdomain.com') WHERE option_name = 'home' OR option_name = 'siteurl' OR option_name = 'widget_text' OR option_name = 'dashboard_widget_options';*/ UPDATE wp_options SET option_value = replace(option_value, 'http://olddomain.com', 'http://newdomain.com');
Running that you your SQL, will do the work.
Regards,
BasilisDecember 3, 2015 at 6:23 pm #546581So I did a test, and it appears the images get the URL path from the domain that is set for the site, as if that part is not stored in the meta data?
So the domain in Multisite settings is abc.123.com and the images get output with that in source path. However, if I change the domain in settings to 123.com, then images get output with that source path.
So that makes me think that there is something dynamic going on during output. Can you help me figure out how and where please? Especially if there is a filter. I need to be able to have consistent URLs and running a DB query is not an option for the rest of my team ha.
Thank you.
December 3, 2015 at 8:44 pm #546632Ok, so I went into database and changed just the site url value and left the home as it was, the subdomain, and the images work properly with the correct (mapped) domain source.
So, images used in shortcodes or builder do not get stored with the domain value it would appear?
December 7, 2015 at 5:53 am #547767Hi!
Yes, that’s correct. It is saved as a post meta data specifically called “_wp_attachment_metadata” in the _postmeta table. The shortcode fetch (wp_get_attachment_image_src) the data whenever needed. Are you trying to change the link of the image element? You don’t have to do anything because the shortcode should handle that automatically.
Best regards,
Ismael -
AuthorPosts
- You must be logged in to reply to this topic.