function msp_get_auto_post_thumbnail_src($post_id = null, $image_from = 'auto', $width = null, $height = null, $crop = null, $quality = 100)
 {
     $post = get_post($post_id);
     $img_src = '';
     if (empty($post)) {
         return '';
     }
     if ('auto' == $image_from) {
         $img_src = has_post_thumbnail($post->ID) ? msp_get_the_post_thumbnail_full_src($post->ID) : '';
         if (empty($img_src)) {
             $content = get_the_content();
             $img_src = msp_get_first_image_src_from_string($content);
         }
     } elseif ('featured' == $image_from) {
         $img_src = has_post_thumbnail($post->ID) ? msp_get_the_post_thumbnail_full_src($post->ID) : '';
     } elseif ('first' == $image_from) {
         $content = get_the_content();
         $img_src = msp_get_first_image_src_from_string($content);
     }
     if (!empty($img_src) && ($width || $height)) {
         return msp_aq_resize($img_src, $width, $height, $crop, $quality);
     }
     return $img_src;
 }
Exemple #2
0
 function msp_get_auto_post_thumbnail_src($post_id = null, $image_from = 'auto')
 {
     $post = get_post($post_id);
     $img_src = '';
     if (!isset($post)) {
         return '';
     }
     if ('auto' == $image_from) {
         $img_src = has_post_thumbnail($post->ID) ? msp_get_the_post_thumbnail_full_src($post->ID) : '';
         if (empty($img_src)) {
             $content = get_the_content();
             $img_src = msp_get_first_image_src_from_string($content);
         }
     } elseif ('featured' == $image_from) {
         $img_src = has_post_thumbnail($post->ID) ? msp_get_the_post_thumbnail_full_src($post->ID) : '';
     } elseif ('first' == $image_from) {
         $content = get_the_content();
         $img_src = msp_get_first_image_src_from_string($content);
     }
     return $img_src;
 }
Exemple #3
0
 function msp_get_auto_post_thumbnail_src($post_id = null, $image_from = 'auto', $size = 'full', $crop = null, $quality = 100)
 {
     $post = get_post($post_id);
     $image = false;
     if (empty($post)) {
         return '';
     }
     if ('auto' == $image_from || 'featured' == $image_from) {
         $image = has_post_thumbnail($post->ID) ? msp_get_the_post_thumbnail_src($post->ID, $size) : false;
     }
     if ('auto' == $image_from) {
         if (!$image || !isset($image[0])) {
             $img_src = msp_get_first_image_src_from_string($post->post_content);
             if (!is_array($size) || !isset($size[1])) {
                 $size = array(null, null);
             }
             $img_src = msp_aq_resize($img_src, $size[0], $size[1], $crop, $quality);
             $image = array($img_src, $size[0], $size[1]);
         }
     } elseif ('first' == $image_from) {
         $img_src = msp_get_first_image_src_from_string($post->post_content);
         if (!is_array($size) || !isset($size[1])) {
             $size = array(null, null);
         }
         $img_src = msp_aq_resize($img_src, $size[0], $size[1], $crop, $quality);
         $image = array($img_src, $size[0], $size[1]);
     }
     return $image;
 }