I need to get the original image for the image type attribute like the default one of thumbnail or small_image on the admin side. You can't seem to use $_prod->getMediaGalleryImages() because if the image is marks as excluded then it an image will not show up there, which makes sense since it's to excluded it from the gallery. You can do something like this

        $_prod = Mage::getModel('catalog/product')->load($product->getId());
        foreach ($_prod->getMediaAttributes() as $attribute) {
            $types[] = $attribute->getAttributeCode();

        echo "PROD", PHP_EOL;
        echo  "id=>",$product->getId(), PHP_EOL;
        echo  "imageTypes=>",$product->getId(), PHP_EOL;

        foreach ($types as $type){
            $imgHelper = Mage::helper('catalog/image');
            $filename = "";
                $filename = Mage::helper('catalog/image')->init($_prod, $type);
            }catch(Exception $e){}
            echo " ==>",$type, PHP_EOL;
            $attrImgs[$type] = $filename."";//force string output
            echo "  ==>",$filename, PHP_EOL;

Which will get you all the assigned images but, they are the cached url paths. Not what I want. I know the image name is in the url as /n/a/name-of-original-file/cached.jpg where name-of-original-file is the original name with out the but processing the string to get that is well not what I want to do. looking at Mage::helper('catalog/image')->init($_prod, $type); shows there is a protect var of _imageFile which is what I seem to need.

I can't seem to find out where I can grab file path or name with out having to pull it through Mage_Catalog_Helper_Image. What I want to end up with is a list of images and the type it belongs to. I have the types done, but I can only get the cached url for the image. Any ideas?

1 Answer 1


You can use


If you just need the main image, otherwise:


Which will return an array, even if marked as exclude.

  • yes, $_prod->getMediaGallery('images') return the list of the attached to product images regardless of if it's excluded which is nice and all, but I need to get what the original file is for lets say small_image, or some custom one I setup called foo_image. Also it should be noted that "If you just need the main image" should be "If you just need the images attached to product". Just to be clear, I'm not looking for the URL, just the file name/path of all image attributes assigned to a product, ie: (defaults) thumbnail,small_image,image (custom) foo_image
    – Quantum
    Commented Mar 30, 2014 at 19:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.