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; }
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; }