Forums

How can I get the img src url using php (5 posts)

  1. johnpwooton
    Member
    Posted 2 years ago #

    Can anyone tell me how to use PHP to dynamically pull the src url for an image?

  2. esmi
    Theme Diva & Forum Moderator
    Posted 2 years ago #

  3. johnpwooton
    Member
    Posted 2 years ago #

    Okay, thanks for that. I'm trying to get the medium image src and this code's size parameter doesn't filter down to the medium size, it only returns the full size. The wp_get_attachment_image will filter down to the medium size, but I need the src url from that, not the actual image.

  4. esmi
    Theme Diva & Forum Moderator
    Posted 2 years ago #

    <?php $uri = wp_get_attachment_image_src( $post->ID, 'medium' );
    echo $uri[0];?>

    works for me.

  5. triggame
    Member
    Posted 1 year ago #

    Thanks Esmi.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags