weirdvision Posted June 23, 2010 Share Posted June 23, 2010 I'm trying to convert an old site that is currently using frames to PHP. The directory structure is the following: /articles /articles/item1 /articles/item1.html /articles.html /index.php In index.php I have the page item1.html included with 'include'. The page item1.html is displayed on the screen when included, but the images that should appear on it are not. The images associated to each itemX.html file are stored in an itemX subfolder of the articles folder. Is it possible to have images displayed without having to change the actual path in each html file? It's a pretty big site, over 400 pages, so I'm looking for minimum amount of changes needed. Thank you in advance! Link to comment https://forums.phpfreaks.com/topic/205625-include-and-path-to-images/ Share on other sites More sharing options...
JAY6390 Posted June 23, 2010 Share Posted June 23, 2010 You could probably use a str_replace on the content of the include before outputting it to achieve this (assuming all images reside in the folders as you described, where it's named as the html page is, without the extension Link to comment https://forums.phpfreaks.com/topic/205625-include-and-path-to-images/#findComment-1076032 Share on other sites More sharing options...
weirdvision Posted June 23, 2010 Author Share Posted June 23, 2010 But isn't that too stressing for the server if it has to be done each time a page is requested? Link to comment https://forums.phpfreaks.com/topic/205625-include-and-path-to-images/#findComment-1076042 Share on other sites More sharing options...
JAY6390 Posted June 23, 2010 Share Posted June 23, 2010 str_replace is highly efficient. Your other option is to create a recursive script to work its way through all the files and save when it does the str_replace on each file. This would only need to be done once Link to comment https://forums.phpfreaks.com/topic/205625-include-and-path-to-images/#findComment-1076045 Share on other sites More sharing options...
weirdvision Posted June 23, 2010 Author Share Posted June 23, 2010 Running a script to change all the files once would me my choice, unfortunately the owner of the site uses a HTML editor to update the site so this method would not work for her. Unless someone comes with another idea I think I will use str_replace at runtime as you suggested. Thank you very much. Link to comment https://forums.phpfreaks.com/topic/205625-include-and-path-to-images/#findComment-1076057 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.