Question

I'm using the Fishpig extension for Magento and I have a list of blog articles from wordpress which shows the link to the main article and the article excerpt, but I also want to show the featured image as a thumbnail.

In the file: /wordpress/post/list/renderer/default.phtml

The object returned by $post = $this->getPost() does not seem to reference any image information, so the function

if ($featuredImage = $post->getFeaturedImage()): always returns null.

How would I get the featured image for each article so that I can show it as a thumbnail next to each article excerpt?

Edit: The accepted answer didn't exactly give the solution but it did point me in the right direction. Turned out Featured Images were not enabled in Wordpress. The solution I found at this link http://wp.tutsplus.com/tutorials/creative-coding/share-your-posts-on-facebook-with-a-preview-image-and-a-description/. Once the plugin was activated it was all pretty easy and now the thumbnail shows.

Was it helpful?

Solution

If a post has a featured image set, getFeaturedImage() will return an image object that can be used to display the image at the available sizes. You can then use any of the following methods to retrieve an image URL:

  • getThumbnailImage()
  • getMediumImage()
  • getLargeImage()
  • getFullSizeImage()
  • getPostThumbnailImage()

If you upload a small image, methods like getLargeImage() will not work. You can use the method getAvailableImage(), which will start at the smallest image and work up until it finds an available image URL.

If getFeaturedImage() is returning null\false, this means a featured image is not set for the post. As always, ensure you have the latest version of the extension available. You can find this at http://fishpig.co.uk/wordpress-integration.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top