...

View Full Version : Replacing multiple images site-wide



actionsigns
02-15-2009, 09:54 PM
Hi all,

I posted this on the Dreamweaver forum on Adobe.com but received two replies unhelpfully telling me to resort to using a database driven site for a catalogue I am developing. I am familiar with using dynamic pages but i do not want this as i want the catalogue to be very spider friendly.

I want to (using some utility or otherwise - maybe javascript) find all broken images within my locally developed website and remove them from the page. Surely there is some utility that will do this for me? I have a static catalogue/portfolio area that is currently being developed. Please see below for further explanation of my query (taken from Adobe.com)

Thanks in advance:


Dear all,

I am producing, in Dreamweaver, a large, image intensive portfolio site which acts as a catalogue for a client.

Each catalogue 'item' (there are hundreds, perhaps over a thousand) has about 7 or 8 images associated with it. The number of images varies, however. Usually 7 or 8, maybe 3 or maybe as much as 25. I have automated many stages in the process apart from this one.

What I want to be able to do is make one item page that i populate the whole site with. Each page coded to contain 30 sequencially numbered thumbnails. Of course, some items will have less than these 30 but there are no items with greater than 30. I then want to use some method in Dreamweaver that will automatically remove the code for all the broken images. To take an example, say there are only 3 images in an item's directory, only three images will not be broken in the code: thumb1, thumb2, thumb3. References to thumb4.jpg onwards, i want to be removed. Is there any way dreamweaver could identify the bolded text and remove across the entire site?:


<img src="thumb1.jpg">
<img src="thumb2.jpg">
<img src="thumb3.jpg">
<img src="thumb4.jpg">
...
<img src="thumb30.jpg">

<img src="big1.jpg">


I have no experience using regular expressions in find and replace, but maybe this is an answer?

Thanks for your help.

R

bazz
02-16-2009, 02:35 AM
So to clarify what you mean (I am tired);

you want the outputted code to show only as many links as there are images? so if there are three images, you output three and if there are 30 you output 30?

I don't know if there is an ajax method but, it would be easiets with a server-side language like php or Perl.

Basically, it would open the relevant folder and build an array from its file content ~ the images. then you could loop thorugh the array to output whatever you need for each image. Likely better for ongoing management, you could put the image names into a db/textfile and use the same language to do loop through its contents. (same thing but just a different data source).


bazz
bazz

harbingerOTV
02-16-2009, 03:34 PM
well as for removing dead links, you can remove those (well all of them) manually. Then in each page (PHP code ahead), you can write:


<?php
$dir = opendir('img1');
$path = "img1";
while ($read = readdir($dir))
{
if ($read!='.' && $read!='..')
{
echo '<img src="'.$path.'/'.$read.'" />';
}
}
closedir($dir);
?>

just change the "img1" to reflect your folders name. The loop will find each item in the folder and wrap them in image tags, so make sure there are only images in the folder.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum