Hi Folks, having a bit of an issue here that i cannot get my head around for some reason. I am working on a site that is a rebuild of an ancient site (its been around since the late 90's) Anyway, all old pages have been put into a database along with the old img tags. These images are randomly place throughout the text in the pages.
Each page is called from one php file. EG: www.mysite.com/post.php?pagename=example The new site is mobile compatible so images need to be displayed as such. I always offer up larger images for desktop devices and smaller ones for mobile.
EG:
<?php
if($ismobile) {
$imgpre= "mobimages";
} else {
$imgpre= "images";
}
?>
<img src="<?php echo $imgpre; ?>/someimage.png" alt="" <?php if($ismobile) {echo 'width="250" height="167"';} else {echo 'width="500" height="333"';} ?>>
At the moment, all the images are stored in the database as normal image tags and i have tried altering them with str_replace or preg_replace but that int going anywhere.
So i have tried this
<img src="getimage.php?imageid=1" width="500" height="677" alt="">
getimage.php is this:
<?php
$imageid = $_GET['imageid'];
$sql = mysqli_query($con, "SELECT image FROM images WHERE id=$imageid");
$row = mysqli_fetch_row($sql);
mysqli_close($con);
header("Content-Type: image/jpeg");
echo $row['image'];
?>
However, this is not working either.
Anyone have any ideas, or suggestions?
Its not a problem to alter the img tags in the database or have them stored seperate along with each page text.
At the moment I am at a loss.