I have a Flickr category among my blogposts where I just paste in the direct links from Flickr, and let OAuth do it’s thing to hotlink/embed the photos in the post.
On my frontpage I am trying to grab the latest hotlinked/embedded photo from the latest post in the Flickr category in order to display it there. But with no success. I’ve tried with the get_the_image();
plugin, but it seems to only read photos that have been inserted into the post using the wordpress gallery.
I manage to get the_title();
, so I know I’m accessing to the right category and post, but I don’t have any chance of displaying the image. Does anyone know how I can achieve this?
Update:
I’ve achieved this with the following code:
query_posts('category_name=flickr&showposts=1');
if ( have_posts() ) : while ( have_posts() ) : the_post();
$meta = get_post_custom();
$photos = array();
foreach ($meta as $key => $value)
if (false !== strpos($key, 'oembed'))
array_push($photos, $value[0]);
if(preg_match('/src="(.+.jpg)"/i', $photos[0], $m)) {
echo '<img src="' . $m[1] . '" />';
}
endwhile;
endif;
Unfortunatly that embeddes the full size image from Flickr. I tried combining it with TimThumb, but with no success. Small steps…
Embeds are cached in hidden custom fields of a post. You can retrieve all keys with
get_post_custom()
of latest post and loop through it, looking for array key that starts wih_oembed_
.