function msp_get_the_post_thumbnail($post_id = null, $width = null, $height = null, $crop = null, $quality = 100) { $image_src = msp_get_the_post_thumbnail_src($post_id, $width, $height, $crop, $quality); return $image_src ? '<img src="' . $image_src . '" alt="" />' : ''; }
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; }