简体   繁体   English

更改wordpress页面上的缩略图大小

[英]Change post thumbnail size on wordpress page

I made a separate wordpress page to display all of my featured images and they do display but I need help on how to make them display to their actual size not as really small images. 我制作了一个单独的wordpress页面来显示我的所有特色图像并且它们显示但是我需要帮助如何使它们显示到它们的实际尺寸而不是真正的小图像。

 <?php
$the_query = new WP_Query();
$the_query->query("cat=4&nopaging=true");

if ($the_query->have_posts()) : 
while($the_query->have_posts()) : $the_query->the_post();

  if(has_post_thumbnail()) : 
    the_post_thumbnail();
  endif;

endwhile; 
endif; 
wp_reset_postdata();
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' ); 
?>

<img src='<?php echo $image[0]; ?>' />

That is my code right now the page is http://rickwarren.veracitycolab.com/banners/ 这是我的代码,现在页面是http://rickwarren.veracitycolab.com/banners/

Thanks! 谢谢!

This is what my new code looks like and the images are still the same any thoughts? 这是我的新代码看起来像什么,图像仍然是相同的想法?

 <?php
$the_query = new WP_Query();
$the_query->query("cat=4&nopaging=true");
if ($the_query->have_posts()) : 
while($the_query->have_posts()) : $the_query->the_post();

  if(has_post_thumbnail()) : 
    the_post_thumbnail();
  endif;

endwhile; 
endif; 
wp_reset_postdata();
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' );
?>

If it still hasn't changed after you've added the 'full' parameter you might want to try the Regenerate Thumbnails plugin: http://wordpress.org/extend/plugins/regenerate-thumbnails/ 如果在添加“完整”参数后仍未更改,则可能需要尝试重新生成缩略图插件: http//wordpress.org/extend/plugins/regenerate-thumbnails/

Usually it helps for me when I've been messing around with custom thumbnail sizes. 通常,当我一直在使用自定义缩略图大小时,它对我有帮助。

The second argument of wp_get_attachment_image_src() is the size of the image to return. wp_get_attachment_image_src()的第二个参数是要返回的图像的大小。 Using full here should give you the full size image. 在这里使用full应该会给你全尺寸的图像。

$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' );

EDIT: Of course this part of your code isn't doing anything since it's outside the loop. 编辑:当然,这部分代码没有做任何事情,因为它在循环之外。

Change line 8 to the_post_thumbnail('full'); 将第8行更改为the_post_thumbnail('full');

You can delete everything after the line that begins with $image... . 您可以删除以$image...开头的行之后的所有内容。 Codex page here 法典页面在这里

Pass wp_get_attachment_image_src(...) a size parameter as well. 传递wp_get_attachment_image_src(...)一个大小参数。 In your case, you want 'full', so wp_get_attachment_image_src( $post->ID, 'full' ) . 在你的情况下,你想要'完整',所以wp_get_attachment_image_src( $post->ID, 'full' ) From the Codex for that function : 来自法典的该职能

$size (string/array) (optional) Size of the image shown for an image attachment: either a string keyword (thumbnail, medium, large or full) or a 2-item array representing width and height in pixels, eg array(32,32). $ size(字符串/数组)(可选)为图像附件显示的图像大小:字符串关键字(缩略图,中,大或全)或表示宽度和高度的2项数组,例如数组(32) ,32)。 As of Version 2.5, this parameter does not affect the size of media icons, which are always shown at their original size. 从版本2.5开始,此参数不会影响媒体图标的大小,这些图标始终以其原始大小显示。

  Default: thumbnail 

CSS rules could still 'shrink' the image though, so if it doesn't work check the URL in the HTML source to confirm that the correct image is being requested, then check the stylesheet. CSS规则仍然可以“缩小”图像,因此如果它不起作用,请检查HTML源中的URL以确认正在请求正确的图像,然后检查样式表。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM