Magento Fishpig how to get post image by id

1k views Asked by At

I have use Fishpig extension in my website.

But i need to show Next and Previous link with it's appropriate featured image.

Can anyone please provide appropriate suggestion for this requirement.

Thanks,

2

There are 2 answers

3
Ben Tideswell On

The following article explains how to get an image object from a post object.

https://fishpig.co.uk/magento/wordpress-integration/post-images/

Specifically:

<?php // $post is already defined ?>
<?php if ($featuredImage = $post->getFeaturedImage()): ?>
    <a href="<?php echo $post->getPermalink() ?>">
        <img src="<?php echo $featuredImage->getAvailableImage() ?>" alt="<?php echo $this->escapeHtml($post->getPostTitle()) ?>"/>
    </a>
<?php endif; ?>
0
Ben Tideswell On

The following code loads a post with the ID of 5 and if a featured image is set, it displays the image and a link to the post.

<?php $post = Mage::getModel('wordpress/post')->load(5) ?>
<?php if ($post->getId()): ?>
    <?php if ($image = $post->getFeaturedImage()): ?>
        <a href="<?php echo $post->getPermalink() ?>">
            <img src="<?php echo $image->getAvailableImage() ?>" alt="<?php echo $this->escapeHtml($post->getPostTitle()) ?>"/>
        </a>
    <?php endif; ?>
<?php endif; ?>

You can find more information on how to get different sized images from the featured image object at the URL below:

https://fishpig.co.uk/magento/wordpress-integration/post-images/