gpt4 book ai didi

wordpress - Magento - Fishpig Wordpress - 特色图片尺寸

转载 作者:行者123 更新时间:2023-12-03 22:25:05 24 4
gpt4 key购买 nike

我使用 Fishpig Wordpress 模块安装了与 Wordpress 集成的 Magento。

大多数 WP 用户都知道,在上传图片时,Wordpress 将创建引用媒体设置中设置的尺寸(例如缩略图大小、中号和大号)的调整大小的版本。它还为您指定的每个自定义缩略图大小创建图像(例如,通过 functions.php)。

似乎 Fishpig Magento 模块仅使用缩略图图像大小。

不幸的是,我需要能够在不同的页面上显示同一图像的不同大小(即 Wordpress 创建的调整大小的版本)。比如分类页面会显示一个小版本,帖子查看页面会显示一个大版本。

我想知道是否有人有过通过此模块检索其他调整大小的图像的经验,因为我找不到太多关于它的文档(或者是否甚至可以使用此模块,因为我也看不到任何建议此功能的代码)。

非常感谢您的帮助。

最佳答案

我有同样的问题......我想创建一个最近的帖子小部件,Fishpig 有很好的记录,但他们没有展示如何为帖子提取特色图像的示例。

但我找到了答案:/app/design/frontend/base/default/template/wordpress/post/list/renderer/default.phtml :

<?php if ($featuredImage = $post->getFeaturedImage()): ?>
<div class="featured-image left">
<a href="<?php echo $post->getPermalink() ?>" title="<?php echo $this->escapeHtml($post->getPostTitle()) ?>"><img src="<?php echo $featuredImage->getAvailableImage() ?>" alt="<?php echo $this->escapeHtml($post->getPostTitle()) ?>"/></a>
</div>
<?php endif; ?>

您可以将“getAvailableImage”更改为其中任何一个,以提取 wordpress 生成的不同图像大小:
getThumbnailImage()
getMediumImage()
getLargeImage()
getFullSizeImage()
getPostThumbnailImage()
getAvailableImage()
getImageByType($type = 'thumbnail')

希望这可以帮助!

关于wordpress - Magento - Fishpig Wordpress - 特色图片尺寸,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16514793/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com