I am trying to get a file name from an image path using basename
and echo it inside the title tag but I can't get it to work since I am echoeing the image path from a functions file.
What I am trying to do now (in product.php):
$path = ProductBekijkPlaatje($contenti[0]['images']);
$basename = basename($path);
echo $basename;
But this breaks the function and only echoes the filepath, while the actual image is lost.
This is the function I am calling (in functions.php):
function ProductBekijkPlaatje($plaatje) {
$path = $img->image_intro;
$basename = basename($path);
$img = json_decode($plaatje);
if ($img->image_intro == '') {
$image = '<img src="images/no-img.jpg" alt="">';
} else {
$image = '<img class="shorterimageimg" title="'.$basename.'" src="cms/'.$img->image_intro.'" alt="'.$img->image_intro_alt.'" >';
}
return $image;
}
I also try to show the image name in the title inside the function, but this isn't working either. What am I doing wrong?