【问题标题】:How to get the largest image based on a thumbnail in wordpress如何根据wordpress中的缩略图获得最大的图像
【发布时间】:2017-05-04 01:09:53
【问题描述】:

我拥有图像缩略图的 URL 访问权限。现在,我想根据 URL 上的缩略图获得最大的图像,但我找不到这个最大的图像。

我检查了 wordpress 图像大小,发现最大的图像是 1024x1024。我的图片是:

www.domain.com/wp-content/uploads/2017-04-sample-image-370x370.jpg

我尝试将维度更改为:

www.domain.com/wp-content/uploads/2017-04-sample-image-1024x1024.jpg

但是,它并没有像我预期的那样工作。另外,我在产品和媒体库中搜索了图片名称,但找不到。

有办法吗?

【问题讨论】:

    标签: wordpress woocommerce


    【解决方案1】:

    查看the_post_thumbnail()。它允许您指定所需的大小:

    https://developer.wordpress.org/reference/functions/the_post_thumbnail/

    // without parameter -> Post Thumbnail (as set by theme using set_post_thumbnail_size())
    the_post_thumbnail();
    
    the_post_thumbnail('thumbnail');       // Thumbnail (default 150px x 150px max)
    the_post_thumbnail('medium');          // Medium resolution (default 300px x 300px max)
    the_post_thumbnail('large');           // Large resolution (default 640px x 640px max)
    the_post_thumbnail('full');            // Original image resolution (unmodified)
    
    the_post_thumbnail( array(100,100) );  // Other resolutions
    

    来源例如:https://codex.wordpress.org/Post_Thumbnails

    【讨论】:

      猜你喜欢
      • 2013-04-25
      • 2014-07-23
      • 1970-01-01
      • 2013-04-06
      • 1970-01-01
      • 1970-01-01
      • 2015-10-24
      • 1970-01-01
      • 2011-04-13
      相关资源
      最近更新 更多