8

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

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

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

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

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

非常感谢您的帮助。

4

2 回答 2

26

我有同样的问题......我想创建一个最近的帖子小部件,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')

希望这可以帮助!

于 2013-06-27T13:34:51.927 回答
0

尝试使用下面的代码。对我来说工作得很好..

echo $featuredImage->getData('guid');

于 2016-05-31T11:21:11.010 回答