• Hi Guys
    Hope somebody can help me out a little here. Have the following code in functions.php, but need to add image sizing, external permalink functions and image alignment to the coding. Anybody able to help me out here???

    Its driving me up the wall. ??

    add_shortcode('thumbnail', 'thumbnail_with_caption_shortcode');
    
    function thumbnail_with_caption_shortcode($atts) {
        global $post;
        $thumbnail = get_the_post_thumbnail($post->ID);
        $thumbnail_id = get_post_thumbnail_id();
        $caption = get_post($thumbnail_id)->post_excerpt;
        $link = get_permalink($thumbnail_id);
        return '<div class="featured-image">'
        . '<a href="' . $link . '">'
        . $thumbnail
        . '<span class="caption">' . $caption . '</span>'
        . '</a>'
        . '</div>';
    }

    thanks in advance
    Allan

Viewing 1 replies (of 1 total)
  • Hi rottyranch,

    Your could try changing
    $thumbnail = get_the_post_thumbnail($post->ID);

    to

    get_the_post_thumbnail( $post->ID, 'thumbnail' );      // Thumbnail (Note: different to Post Thumbnail)
    get_the_post_thumbnail( $post->ID, 'medium' );         // Medium resolution
    get_the_post_thumbnail( $post->ID, 'large' );          // Large resolution
    get_the_post_thumbnail( $post->ID, 'full' );           // Original resolution

    For alignment you may want to amend or create some CSS targeting the .featured-image class.

    Have a look at this article for more info.

    Let me know how you get on.
    Drew

Viewing 1 replies (of 1 total)
  • The topic ‘Additional Featured Image Coding’ is closed to new replies.