Forums

[Plugin: User Photo] How do I return just the image URL? (7 posts)

  1. anonymous-surfing-tips
    Member
    Posted 2 years ago #

    I'm attempting to modify the RSS feed and only need the author image URL

    <?php userphoto_the_author_thumbnail(); ?>
    returns

    <img width="80" height="80" class="photo" alt="author name" src="http://domain.com/wp-content/uploads/userphoto/author.name.jpg"/>

    What returns
    http://domain.com/wp-content/uploads/userphoto/author.name.jpg
    ??
    Thanks for any assistance you can offer.

  2. JordashTalon
    Member
    Posted 2 years ago #

    I would like to know that as well.

  3. dikkevandale
    Member
    Posted 2 years ago #

    +1

  4. dikkevandale
    Member
    Posted 2 years ago #

    Lol, I just did this :)

    <img src=<?php bloginfo(url);?>/wp-content/uploads/userphoto/<?php echo strtolower($curauth->nickname); ?>.jpg" title="<?php echo $curauth->nickname; ?>" alt="userphoto"/></a>

    I don't know if it works on all users.. And it always should be .jpg :)

  5. spacechampion
    Member
    Posted 2 years ago #

    that will only work if the photo is a jpg.

  6. dikkevandale
    Member
    Posted 2 years ago #

    That's what I said in my post :)

  7. eddyfly
    Member
    Posted 2 years ago #

    Not wanting to mess about with the plugin, I did this on the font end instead.

    // regular expression:
    $matchSrc = "/src=[\"' ]?([^\"' >]+)[\"' ]?[^>]*>/i" ;
    // get the <img src="... from the plugin, via one on various methods explained in the documentation...
    $avatar = get_avatar($user->ID, 64); // for example
    // preg match to extract the src= bit
    preg_match($matchSrc, $avatar, $matches);
    $theImageUrl = $matches[1];

    That gives you everything between src="[...]".

    I wanted to use it for the background of a div...

    echo "<div style='background:url($theImageUrl) center no-repeat;'>";

    I hope it helps :)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags