I have a dir structure like:
IMAGES/
imgex2.png
s_imgex2.png
imgre.png
s_imgre.png
Where imgex2.png and imgre.png are the big images and s_imgex2.png and s_imgre.png are thumbnails
I want to fill a gallery with absolute path in php like
<li><a href="www.site.com/images/imgex2.png">
<img src="images/s_imgex2.png" alt="ex2" />
</a></li>
<li><a href="www.site.com/images/imgre.png">
<img src="images/s_re.png" alt="re" />
</a></li>
How to fill given a path a gallery with the big image first and then the thumbnail (it has a "s_" at the begining of filename) and put in alt="" the name without the "img" string? the issue here is not always the filenames have "img" so trim is not an option
Other problem is getcwd() returns 'file:///D:/Hosting/2543486/html/site/images' not www.mysite.com
I was doing
<?
$dir = './';
$files = glob( $dir . '*.png');
foreach( $files as $file) {
$path = getcwd().$file;
$path = substr_replace($path, 'file:///D:/Hosting/2543486/html/', 0);
$site = "http://www.site.com/".$path.$file;
$thumb_site = "http://www.site.com/".'s_'.$path.$file;
$alt = substr_replace($file, 'img', 0);
echo '<li><a href="'.$thumb_site.'">';
echo ' <img src="'.$thumb_path.'" alt="'.$alt.'" />';
echo '</a></li>';
}
?>
but getting:
http://www.site.com/file:///D:/Hosting/2543486/html/site/imgex2.png
http://www.site.com/s_file:///D:/Hosting/2543486/html/site/imgex2.png
How to solve it?
Hosting\2543486\html\siteorHosting\2543486\html? - Passerby