如何 回显"text" 仅当附加的缩略图大于 WordPress 中的"X"分辨率时?



有人可以帮我解决以下问题吗?

如何仅在 WordPress 中附加的缩略图分辨率超过 500px x 500px 时才回显"文本"?

如果附加的缩略图大于指定的图像分辨率,我想回显链接。

谢谢。

找到了解决方案

<?php $imgdata = wp_get_attachment_image_src( get_post_thumbnail_id(), 'thumbnail' );
                    $imgurl = $imgdata[0]; // the url of the thumbnail picture
                    $imgwidth = $imgdata[1]; // thumbnail's width
                    $imgheight = $imgdata[2]; // thumbnail's height
                    if ($imgwidth >= 200 || $imgheight >= 200){
                        echo 'Success';
                    } else {
                    echo "Nope";
                    }?>

试试这个:

$size = imagegetsize($image);
if ($size[0] <= 500 || $size[1] <= 500){
  echo "text";
} else {
  echo "<img src=...>"
}

最新更新