Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento - Fishpig Wordpress - Featured image sizes

I have an installation of Magento that integrates with Wordpress using the Fishpig Wordpress module.

As most WP users will know, when uploading an image Wordpress will create resized versions referencing the dimensions set in Media Settings (e.g. Thumbnail Size, Medium Size and Large Size). It also creates images for each custom thumbnail size you specify (e.g. via functions.php).

It appears as though the Fishpig Magento module only uses the Thumbnail image size.

Unfortunately I need to be able to display different sizes of the same image (i.e. the resized versions that Wordpress creates) on different pages. For example, the category page will display a small version, the post view page will display a larger version.

I was wondering if anyone has had any experience retrieving the other resized images via this module as I can't find much documentation on it (or if it's even possible with this module as I also couldn't see any code that would suggest this functionality).

Greatly appreciate the help.

like image 965
lee Avatar asked May 13 '13 04:05

lee


1 Answers

I had the same issue...I wanted to create a recent posts widget and Fishpig has that well documented, but they didn't show an example of how to pull the featured image for the post.

But I found the answer in: /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; ?>

You can change "getAvailableImage" to anyone of these to pull the different images sizes that wordpress produces:

getThumbnailImage()
getMediumImage()
getLargeImage()
getFullSizeImage()
getPostThumbnailImage()
getAvailableImage()
getImageByType($type = 'thumbnail')

Hope this helps!

like image 88
Tranman Avatar answered Oct 25 '22 08:10

Tranman