Create a sub-list of images

I have a slideshow at the top of my product description.

This slideshow uses photos from the images list of the product. I still have a photo gallery. To do the differentiation, the previous programmer uses the following rule : if a photo is excluded from gallery, then it is in slideshow.

This solution was good till now, as now, I want as well to have a photo for my category listing (i.e. small photo) and that photo should be neither in the slideshow nor in the gallery.

For the images, Is there a way to add a column (in backend), similar to the "Exclude" one, so that I can have a column "Slideshow" and restore the Exclude functionality to its original.

While I'm at it, how should I do then to fetch this so defined Slideshow list?

Solutions

OK, I got 2 working solutions

1. From the template

Display the image if the condition on the position is filled-in

  <?php foreach ($this->getGalleryImages() as $i => $_image): ?>
        <?php if($_image->getPosition()<100){ //Display in Gallery only those with position below 100 ?>
        //Display the image here
    <?php } ?>
<?php endforeach; ?>

2. overwrite the extracting function

public function getGalleryImages($min=0,$max=0)
{
    if ($this->_isGalleryDisabled) {
        return array();
    }

    $product = $this->getProduct();
    if(!$product->hasData('media_gallery_images') && is_array($product->getMediaGallery('images'))) {
        $images = new Varien_Data_Collection();
        foreach ($product->getMediaGallery('images') as $image) {
            if ($image['disabled']) {
                continue;
            }
            if($min!==$max AND ( $image['position']<$min OR $image['position']>$max )){
                continue;
            }
            $image['url'] = $product->getMediaConfig()->getMediaUrl($image['file']);
            $image['id'] = isset($image['value_id']) ? $image['value_id'] : null;
            $image['path'] = $product->getMediaConfig()->getMediaPath($image['file']);
            $images->addItem(new Varien_Object($image));
        }
        return $images;
    }
}

Note that I added a fallback for all previous call to this function, the min and max will both be at 0 disabling the extra thing.

You could add a new image attribute slideshow_image to the products attribute set. This post on pixafy explains how. This would enable you to retrieve all the images for the product collection slidehow by search for the images in the slideshow_image attribute.

Tags: Image / Gallery

Similar questions

Magento : Get Sub-Categories and 8 Products From Each Sub-Category
I want to make a landing page for Magento 1.9.3.4. What I got is the following: Head category: Computer Sub-categories from Computer: Harddisk, Monitor, Cables, Keyboards. I want to make a page for "Computer" where all the sub-categories will be shown and 8 products from each sub-category. How can I do this in best way?
How to get sub category of sub category?
I have to load parent category, sub category and its sub categories. As of now, I can able to load the parent and its sub category but I have no idea how to load its sub category. Below is the code I have used in template file: Code in block file: Can anyone please help me to load sub categories of sub category? Code Tried: Code used in phtm:
Magento - get a parent category and all sub-sub-categories
I have a single category, that has 2 subcategories. Within each of these categories, are 5 subcategories. Is there a way to get a list of all of these 10 sub-sub-categories? Thanks EDIT: Something like this: Thanks
Display all products of a sub-category on a new or existing phtml page when clicking on a sub-category from Magento home-page
I have displayed all parent categories and sub-categories in the home page (left.phtml). I want each sub-category to be a link which directs to a page where the products of that sub-category should be listed. Nothing is working right now. When clicking on the sub-category, it gives page not found error. Also nothing is showing in the getProductCoun...
Magento Layered Navigation - Hide Sub-sub categories
I'm currently developing a website for a client and I've hit a bit of a snag. We're using FME Layered Navigation, which currently displays both sub & sub-sub categories of the parent category. What we'd like is to just show the sub categories, then once that is clicked show the sub-sub categories. e.g: If anybody could point me in the right dir...
PSR4 Sub-directory don't match the case of the sub-namespace names
According to psr4 sub-directory must match the case of the sub-namespace names The contiguous sub-namespace names after the “namespace prefix” correspond to a subdirectory within a “base directory”, in which the namespace separators represent directory separators. The subdirectory name MUST match the case of the sub-namespace names. But when I look...

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy.