I like to work locally on my drupal website until it is finished.

When I insert an image (local) on my site with imageassist, it creates a link like "http://localhost/ ..." (my base url). Everything works fine. But when I publish my site on the net, this link is offcourse not right. So I have to edit the image link in order to work correct. When having hunderts of images, this is very time consuming!

Is there a solution so I don't have to edit all the corrupt links?

Thanks!

Comments

cog.rusty’s picture

Look for those strings in the database. Normally you should not find them (except maybe in the cache table), because only relative paths should be stored in the database and they are rebuilt for display (except if you have entered them manually in the content).

If it is not a cache problem (which can be solved by truncating the cache table in the database) then it is an imageassist bug.

If a problem actually exists in the database and you have to do bulk search and replace, perhaps the easiest and fastest way is to (carefully) use a text editor on (a copy of) the database dump file before uploading it.

hyperlogos’s picture

Instead of <img> tags. That would have linked images by nid instead of by path.

Now, those tags are stored in the BODY of each of your nodes. That means that in order to fix this in an automated fashion you'd basically have to write a script that would build a list of nodes whose contents field contains the string 'img src="http://localhost'. then you'd have to go through that list, retrieve every node's content field, change the URL (something like s/img src="http://localhost/\(.+\)"/img src="http://myrealaddress.com/\1"/gi) and then do a SQL UPDATE statement for each corrected contents field, in order to stuff it back into the database.

This is why img_assist.module provides the filter, and lets you use img_assist filter tags instead of IMG tags - it avoids just this problem. You change the name of your site or your URL, or even the name of an image, and it still works properly.

You are pretty much hosed and will either have to fix it manually or write a script to fix it. MySQL might (if you are lucky) have some kind of string handling functions that will help you though; you might actually be able to just do it as a SQL statement.

However, nothing you can do from inside drupal can help you now.

If you ARE using img_assist filter tags, then disregard all of the above, and just go to your sites/default/settings.php and change your base URL :)