wp_get_attachment_image_src( int $attachment_id, string|array $size = ‘thumbnail’, bool $icon = false )
Retrieve an image to represent an attachment.

–> http://example.com/wp-content/uploads/2017/11/image-name-150×150.jpg

$sized = image_downsize( $post_id, ‘thumbnail’ );
if ( $sized )
return $sized[0];

if ( !$thumb = wp_get_attachment_thumb_file( $post->ID ) )
    return false;

$url = str_replace(basename($url), basename($thumb), $url);

发表评论

您的电子邮箱地址不会被公开。