I have a simple function that has two parameters: one for the image URL and the other for image attributes
function image_found($url,$attributes) { if(@getimagesize($url)) { echo '<img src="'.$url.'" '.$attributes.'/>'; } else { echo '<img src="'.base_url().'/site_images/image_not_found.svg" '.$attributes.'/>'; } }
now what I'm trying to do is create a clickable image, if the image is found, now it's html code
echo '<div class="panel-body">'; echo '<div class="col-md-12 col-lg-12 col-sm-12 text-center">'; $url = base_url().'product_images/'.$result->product_image.'.'.$result->image_type; $attributes = 'height="200px" width="100%"'; echo '<a href="product.com/full/url">'.image_found($url,$attributes).'</a>'; echo '</div>'; echo '</div>';
and this is the result that I get
<div class="panel-body"> <div class="col-md-12 col-lg-12 col-sm-12 text-center"> <img src="http://localhost/nsc/product_images/7908076366784972032090.jpg" height="200px" width="100%"/> <a href="#"></a> </div> </div>
I do not know what is wrong here, I use bootstrap
source share