Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8496695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:55:26+00:00 2026-06-10T23:55:26+00:00

I have a block on my front page that is grabbing the two newest

  • 0

I have a block on my front page that is grabbing the two newest products with a custom product image called image_feature_front_right.

I use this code as the query:

$_helper = $this->helper('catalog/output');
$_productCollection = Mage::getModel("catalog/product")->getCollection();
$_productCollection->addAttributeToSelect('*');
$_productCollection->addAttributeToFilter("image_feature_front_right", array("notnull" => 1));
$_productCollection->addAttributeToFilter("image_feature_front_right", array("neq" => 'no_selection'));
$_productCollection->addAttributeToSort('updated_at', 'DESC');
$_productCollection->setPageSize(2);

I am able to get:

  • the image: echo $this->helper('catalog/image')->init($_product, 'image_feature_front_right')->directResize(230,315,4)
  • the product url: echo $_product->getProductUrl()
  • the product name: $this->stripTags($_product->getName(), null, true)

The only thing I am unable to get is the custom images label. I have tried echo $this->getImageLabel($_product, 'image_feature_front_right'), but that seems to do nothing.

Can anyone point me in the right direction?

Thanks!

Tre

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T23:55:28+00:00Added an answer on June 10, 2026 at 11:55 pm

    I imagine this is some sort of magento bug. The issue seems to be that the Magento core is not setting the custom_image_label attribute. Whereas for the default built-in images [image, small_image, thumbnail_image] it does set these attributes – so you could do something like:

    $_product->getData('small_image_label');
    

    If you look at Mage_Catalog_Block_Product_Abstract::getImageLabel() it just appends ‘_label’ to the $mediaAttributeCode that you pass in as the 2nd param and calls $_product->getData().

    If you call $_product->getData('media_gallery'); you’ll see the custom image label is available. It’s just nested in an array. So use this function:

    function getImageLabel($_product, $key) {
        $gallery = $_product->getData('media_gallery');
        $file = $_product->getData($key);
        if ($file && $gallery && array_key_exists('images', $gallery)) {    
            foreach ($gallery['images'] as $image) {
                if ($image['file'] == $file)
                    return $image['label'];
            }
        }
        return '';
    }
    

    It’d be prudent to extend the Magento core code (Ideally Mage_Catalog_Block_Product_Abstract, but I don’t think Magento lets you override Abstract classes), but if you need a quick hack – just stick this function in your phtml file then call:

    <?php echo getImageLabel($_product, 'image_feature_front_right')?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a custom block loading products on my front page that loads the
I have a view that I am using for articles on the front page
I have a block of HTML code that contains a button <button class=someButton onclick=openPage('test')></button>
I have a block of text that I need to give a background colour
If have if block like that if(foo() || foo2() || foo3()) { //do some
I have a block of text and each word in it, that starts from
I have a block element (DIV) who stretches across an entire page. It contains
Okey, here it goes. I have a block of code that repeats it self
I have this button, that should go to the page in the value, but
I have some list items with anchor tags, that are set to display block

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.