Advertisement
Guest User

Thumbnail getter for wordpress templates

a guest
Jul 13th, 2011
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.85 KB | None | 0 0
  1. // Logik Thumbnail Getter
  2. function logik_thumbnail() {
  3.     if (is_home()) { $img_url = get_option('logik_fbimgurl'); }
  4.     elseif(has_post_thumbnail( $post->ID )) {
  5.         $thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'thumbnail' );
  6.         $img_url = $thumb['0'];
  7.     } else {
  8.     //function to call first uploaded image in functions file
  9.     $files = get_children('post_parent='.get_the_ID().'&post_type=attachment
  10.     &post_mime_type=image&order=desc');
  11.       if($files) :
  12.         $keys = array_reverse(array_keys($files));
  13.         $j=0;
  14.         $num = $keys[$j];
  15.         $img_url=wp_get_attachment_thumb_url($num);
  16.       endif;
  17.     }
  18.     if ( $img_url == '' ) {
  19.         $img_url = get_option('logik_fbimgurl');
  20.     }
  21.     if ( $img_url == '' ) {
  22.         get_option('logik_fbimgurl');
  23.         $template=get_theme_root_uri();
  24.         $img_url = $template .'/ThemeName/images/defaultimage.jpg';
  25.     }
  26.     echo $img_url;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement