• I’m using a function to echo thumbnails on my homepage from uploaded images in a post. That works fine. I’d like to do the same thing if a post only has images in which the src hotlinks to my Flickr photos.

    How can I add an either/or function that grabs that path? Can I?

    Here’s the code I’m currently using:

    From the functions file:

    # Displays post image attachment (sizes: thumbnail, medium, full)
    function dp_attachment_image($postid=0, $size='thumbnail', $attributes='') {
    	if ($postid<1) $postid = get_the_ID();
    	if ($images = get_children(array(
    		'post_parent' => $postid,
    		'post_type' => 'attachment',
    		'numberposts' => 1,
    		'post_mime_type' => 'image',)))
    		foreach($images as $image) {
    			$attachment=wp_get_attachment_image_src($image->ID, $size);
    			?><div style="background:#FFF url(<?php echo $attachment[0]; ?>) no-repeat center center;">&nbsp;</div><?php
    		}

    And from then the homepage goes:

    <div class="thumb"><?php dp_attachment_image($post->ID, 'medium', 'alt="' . $post->title . '"'); ?></div>
  • The topic ‘How to get Flickr thumbnails from post?’ is closed to new replies.