I'm having trouble taking pictures from the database in php. If I create cards in the same format with the Foreach loop, there is no problem, but I cannot use foreach when the picture sizes and card sizes are different like as in https://seyler.eksisozluk.com. That's a lot of invoking php file as it needs to provide separate control for each card. I think I made a mistake somewhere on the ground, but I need to find a sustainable solution. I wrote a control mechanism because the pictures don't always have to be on the url or server
<?php
$random_img = rand(1,9);
$fixed_image = "<img src='public/img/duz/img_".$random_img.".jpg' style='width: 100%; height:140px; filter: blur(.1rem);' border:2px solid red;>";
$file = "public/upload/$image1"; //$image1 = $array_main_posts[0]['content_foto'];
$img_url = $image1;
$find_letters = array('jpg', 'jpeg', 'png','gif','svg');
//print_r($image_url_length);
$match = (str_replace($find_letters, '', substr($img_url,-4)) != substr($img_url,-4));
//img_url 's if last 4 characters does not match with array value's last for caracter 4 it returns false if else returns true
if (empty($image1)) {
echo "";
?>
<script>
$( '#content_image' ).css('display', 'none');
</script>
<?php
}elseif (file_exists($file)) {
echo "<img style='width:100%; height:250px' src='".$file."'>";
//print_r($file);
}elseif (strlen($img_url)>=3) { //if value's length that comes from database is mor than three
if (filter_var($img_url, FILTER_VALIDATE_URL)!==false && $match==true) {
echo "<img style='width:100%; height:250px' src='".$img_url."'>";
//echo "<img style='width:100%; height:400px' src='".$img_url."'><span>image information</span>"; subtitle
}else{?>
<script>
$( '#icerik_resim' ).css('display', 'none');
</script>
<?php
}
//print_r($img_url);
}else{
echo $fixed_image;
echo '<div style="position:absolute; left:15px; bottom:5px; text-decoration: none;"><span>Merhaba</span></div>';
}
?>
I'm bringing an img tag to a certain size with this code, but I'm going to have to call a separate php file with this code for each different card, as the dimensions on the cards will be different, I don't know what I can do instead.
this is the current page image: