Magento 2 - Image Label returning Product name
I am trying to display a Product Image
but am not able to get the correct data for the Alt Text
$image = $block->getImage($_product, 'category_page_grid');
When I call $image->getLabel()
it is returning the name of the Product
rather than the Alt Text
magento2
add a comment |Â
I am trying to display a Product Image
but am not able to get the correct data for the Alt Text
$image = $block->getImage($_product, 'category_page_grid');
When I call $image->getLabel()
it is returning the name of the Product
rather than the Alt Text
magento2
add a comment |Â
I am trying to display a Product Image
but am not able to get the correct data for the Alt Text
$image = $block->getImage($_product, 'category_page_grid');
When I call $image->getLabel()
it is returning the name of the Product
rather than the Alt Text
magento2
I am trying to display a Product Image
but am not able to get the correct data for the Alt Text
$image = $block->getImage($_product, 'category_page_grid');
When I call $image->getLabel()
it is returning the name of the Product
rather than the Alt Text
magento2
magento2
asked Nov 10 at 21:42
Shawn Northrop
2,90643157
2,90643157
add a comment |Â
add a comment |Â
2 Answers
2
active
oldest
votes
That question has been answered similarly on Stackexchange: https://magento.stackexchange.com/questions/210995/media-image-attribute-width-height-and-alt-tag-in-a-phtml-magento-2
Use this and call $image->getAttribute('alt')
add a comment |Â
Apparently you need to call addMediaGalleryData()
if you want to get the Alt
information.
$items = $block->getProductCollection()->addMediaGalleryData()->getItems();
foreach($items as $_product)
$values = ($_product->getMediaAttributeValues());
$images = $_product->getMediaGalleryImages();
I could not find a way to get the Alt
value when calling
$image = $block->getImage($product, 'category_page_grid')
Though I could loop through the $images
and reference the image name that matched $image
and get the Alt
value from there.
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
That question has been answered similarly on Stackexchange: https://magento.stackexchange.com/questions/210995/media-image-attribute-width-height-and-alt-tag-in-a-phtml-magento-2
Use this and call $image->getAttribute('alt')
add a comment |Â
That question has been answered similarly on Stackexchange: https://magento.stackexchange.com/questions/210995/media-image-attribute-width-height-and-alt-tag-in-a-phtml-magento-2
Use this and call $image->getAttribute('alt')
add a comment |Â
That question has been answered similarly on Stackexchange: https://magento.stackexchange.com/questions/210995/media-image-attribute-width-height-and-alt-tag-in-a-phtml-magento-2
Use this and call $image->getAttribute('alt')
That question has been answered similarly on Stackexchange: https://magento.stackexchange.com/questions/210995/media-image-attribute-width-height-and-alt-tag-in-a-phtml-magento-2
Use this and call $image->getAttribute('alt')
answered Nov 13 at 12:04
Tobi
836
836
add a comment |Â
add a comment |Â
Apparently you need to call addMediaGalleryData()
if you want to get the Alt
information.
$items = $block->getProductCollection()->addMediaGalleryData()->getItems();
foreach($items as $_product)
$values = ($_product->getMediaAttributeValues());
$images = $_product->getMediaGalleryImages();
I could not find a way to get the Alt
value when calling
$image = $block->getImage($product, 'category_page_grid')
Though I could loop through the $images
and reference the image name that matched $image
and get the Alt
value from there.
add a comment |Â
Apparently you need to call addMediaGalleryData()
if you want to get the Alt
information.
$items = $block->getProductCollection()->addMediaGalleryData()->getItems();
foreach($items as $_product)
$values = ($_product->getMediaAttributeValues());
$images = $_product->getMediaGalleryImages();
I could not find a way to get the Alt
value when calling
$image = $block->getImage($product, 'category_page_grid')
Though I could loop through the $images
and reference the image name that matched $image
and get the Alt
value from there.
add a comment |Â
Apparently you need to call addMediaGalleryData()
if you want to get the Alt
information.
$items = $block->getProductCollection()->addMediaGalleryData()->getItems();
foreach($items as $_product)
$values = ($_product->getMediaAttributeValues());
$images = $_product->getMediaGalleryImages();
I could not find a way to get the Alt
value when calling
$image = $block->getImage($product, 'category_page_grid')
Though I could loop through the $images
and reference the image name that matched $image
and get the Alt
value from there.
Apparently you need to call addMediaGalleryData()
if you want to get the Alt
information.
$items = $block->getProductCollection()->addMediaGalleryData()->getItems();
foreach($items as $_product)
$values = ($_product->getMediaAttributeValues());
$images = $_product->getMediaGalleryImages();
I could not find a way to get the Alt
value when calling
$image = $block->getImage($product, 'category_page_grid')
Though I could loop through the $images
and reference the image name that matched $image
and get the Alt
value from there.
answered Nov 13 at 17:48
Shawn Northrop
2,90643157
2,90643157
add a comment |Â
add a comment |Â
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid â¦
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid â¦
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53243693%2fmagento-2-image-label-returning-product-name%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown