Forums

How to get medium size attachment url? (3 posts)

  1. Mansur
    Member
    Posted 2 years ago #

    After 5 days I search for retrieve url attachment thumbnail finally found as follow:

    <?php
    $thumb = $wpdb->get_var("SELECT ID FROM $wpdb->posts where post_parent= $post->ID and post_type = 'attachment'");
    $thumbnail = wp_get_attachment_thumb_url($thumb);?>
    echo '$thumbnail';

    above code will display: http://www.mysite.com/images/thumb.jpg.

    BUT similar as above:

    I want the retrieve MEDIUM side image URL:

    I Tried replacement : wp_get_attachment_medium_url
    but contain errors as follow:
    atal error: Call to undefined function wp_get_attachment_medium_url()

    Please help me, TQ in advance...

  2. alexmglover
    Member
    Posted 2 years ago #

    $img = wp_get_attachment_image($attachment_id, $size='medium', $icon = false);

    I would just grab your attachment id by some means and plug it in here. I would assume you could just echo the $img and print out the link. Hope that helps... and hope it works.

  3. Mansur
    Member
    Posted 1 year ago #

    The best solution ever for get medium thumbnail url source

    http://codex.wordpress.org/Function_Reference/image_downsize

Topic Closed

This topic has been closed to new replies.

About this Topic