自定义字段-显示缩略图(并自动调整大小)
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了自定义字段-显示缩略图(并自动调整大小)相关的知识,希望对你有一定的参考价值。
Whilst there are a number of ways of displaying thumbnails, this is still my favourite (even if it does require the most work!). First, upload timthumb to /wp-content/themes/yourtheme/ and create an image 250px by 250px with your site’s logo and upload it to yourtheme/images/. This is the image that will be displayed if no custom field is displayed. Then, for every thumbnail, you’ll need to create it in Photoshop and upload it to your blog. Next, create a custom field ‘Image’ with the path of the image as the value of the custom field. Now for the code:
if ($postimageurl) { ?> <img src="/wp-content/themes/NomeMag/scripts/timthumb.php?src=<?php echo get_post_meta($post->ID, "Image", true); ?> &h=250&w=250&zc=1" alt=""> <?php } else { ?> <img src="/wp-content/themes/NomeMag/images/wpshoutlogo.jpg" alt="WPShout.com | No image available" /> (don't have a line break, just so it's readable) <?php } ?>
以上是关于自定义字段-显示缩略图(并自动调整大小)的主要内容,如果未能解决你的问题,请参考以下文章