Example #1
0
 function attach_img($args)
 {
     $defaults = array('post_id' => false, 'attach_id' => false, 'url' => false, 'meta_slug' => false, 'option_slug' => false, 'size' => 'full', 'echo' => true);
     extract(wp_parse_args($args, $defaults));
     if (!$url and !$post_id) {
         global $post;
         $post_id = $post->ID;
     }
     // Try the meta slug first
     if (!$url and $meta_slug) {
         $url = ricUtil::meta($post_id, $meta_slug, false);
     }
     // Then the option slug
     if (!$url and $option_slug) {
         $url = ricUtil::opt($option_slug, false);
     }
     if ($url) {
         $attach_id = ricUtil::attach_id($url);
     }
     if ($attach_id) {
         $img = wp_get_attachment_image($attach_id, $size, false);
         if ($echo) {
             echo $img;
         }
         return $img;
     }
     return false;
 }