• I have a strange problem, when I try to enter the source of an image tag using PHP it shows me the following error in the inspector

    <img src=(unknown) alt="">

    this code fragment gives me the correct url, checked by seeing the CPanel and pasting and copying the address,but when I try to enter it via php the image is not shown

    $image = wp_get_attachment_image_src( $post_thumbnail_id); 
    //echo($image[0]);
    ?>
    <img src="<?php $image[0]; ?>" alt="">

    The next thing I did was an echo of image[0] and it gave me the url of the image, I copied it and pasted it in the tag and that’s when it showed me the image

    <img src="mysite.com/wp-content/uploads/2018/11/957a...150x150.jpg" alt="">

    I saw the page in Incognito Window and I did not show the image either.

    Any clues?

Viewing 2 replies - 1 through 2 (of 2 total)
  • <img src="<?php $image[0]; ?>" alt="">
    This PHP is not echoing the variable. It is just a variable expression.

    Dion

    (@diondesigns)

    Add the echo inside the PHP tag just like you did in the commented-out line:

    <img src="<?php echo $image[0]; ?>" alt="">
    
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Cant display an image inputing the source via PHP’ is closed to new replies.