Magento 2 - Image Label returning Product name
up vote
0
down vote
favorite
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 |
up vote
0
down vote
favorite
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 |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
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,90143057
2,90143057
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
up vote
0
down vote
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 |
up vote
0
down vote
accepted
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
up vote
0
down vote
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 |
up vote
0
down vote
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 |
up vote
0
down vote
up vote
0
down vote
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
666
666
add a comment |
add a comment |
up vote
0
down vote
accepted
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 |
up vote
0
down vote
accepted
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 |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
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,90143057
2,90143057
add a comment |
add a comment |
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