By I am learning on
Hi,
When we insert an image using FCKEditor and IMCE, the path is set as "/sites/default/files/myimage.jpg". Now if we move the site to sub-directory, it should be "sub-directory/sites/default/files/myimage.jpg". Updating one by one all nodes not possible. What is the fastest way?
Thanks
Comments
Perform a search and replace
Perform a search and replace query in your phpMyAdmin panel.
Not sure how to do this? An
Not sure how to do this? An example will be really helpful.
Thanks
if image urls inside node
if image urls inside node content
i know a manually method :
this way: export data > replace all X > import data
if you access to phpmyadmin and can export
go to your drupal DB > node_revisions
then click export data
uncheck save file
php my admin export your node data
select all at:
INSERT INTO `ak_node_revisions` (`nid`, `vid`, `uid`, `title`, `body`, `teaser`, `log`, `timestamp`, `format`) VALUES
...
..
.
to end
then copy and past in editor like notepad
use find/replace
find: "/sites/default/files/
replace: "sub-directory/sites/default/files/
replace all
then copy all
in phpmyadmin "node_revisions" empty data
click SQL top of phpmyadmin menu
in "Run SQL query/queries on database" delete all query
and paste changed data that you copied from notpad
INSERT INTO `ak_node_revisions` (`nid`, `vid`, `uid`, `title`, `body`, `teaser`, `log`, `timestamp`, `format`) VALUES
...
..
.
to end
This sounds good, can we
This sounds good, can we write an update sql statement for the same?
htaccess solution
You've got htaccess / clean_urls enabled, right? If you modify your htaccess file you can do this with a rewrite rule:
You want to add this in your htaccess file right after the RewriteEngine On command:
Thanks, its a great solution
Thanks, its a great solution but I would like to update this in DB directly.
Regards
MySql REPLACE(str,from_str,to_str)
REPLACE(str,from_str,to_str)
Returns the string str with all occurrences of the string from_str replaced by the string to_str. REPLACE() performs a case-sensitive match when searching for from_str.
update TABLE_NAME set FIELD_NAME = replace(FIELD_NAME, ‘find this string’, ‘replace found string with this string’);
i think you must run it:
update XX_node_revisions set body = replace(body, ‘/sites/default/files/’, ‘sub-directory/sites/default/files/’);
Note: XX table prefix
Great, thank you so much.
Great, thank you so much.
Have a look here: Solution
Have a look here: Solution to: Images disappear when moving site to/from a subdirectory.