Magento2 Custom Media Image Attribute do not work in Frontend Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30 pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?Extending the complexType named “imageType” with a custom image typeREST API creating more than one media entry for productGetting a custom attribute imageSwatch attribute ImageMagento2 Product import (image filenames)Media image attribute bugged in frontendMagento 2 get cached url full path of custom attributeGet product image by its “Role” in the galleryNeed to import product image from Media library while updating product imagesMagento 2 model for adding images to media folder (not for products)?
How long can a nation maintain a technological edge over the rest of the world?
Is there a verb for listening stealthily?
false 'Security alert' from Google - every login generates mails from 'no-reply@accounts.google.com'
What's called a person who works as someone who puts products on shelves in stores?
Bright yellow or light yellow?
How would you suggest I follow up with coworkers about our deadline that's today?
Are there existing rules/lore for MTG planeswalkers?
What is ls Largest Number Formed by only moving two sticks in 508?
Why isn't everyone flabbergasted about Bran's "gift"?
What was Apollo 13's "Little Jolt" after MECO?
Does using the Inspiration rules for character defects encourage My Guy Syndrome?
Arriving in Atlanta (after US Preclearance in Dublin). Will I go through TSA security in Atlanta to transfer to a connecting flight?
How would it unbalance gameplay to rule that Weapon Master allows for picking a fighting style?
Is there an efficient way for synchronising audio events real-time with LEDs using an MCU?
Has a Nobel Peace laureate ever been accused of war crimes?
Why doesn't the university give past final exams' answers?
How to translate "red flag" into Spanish?
What *exactly* is electrical current, voltage, and resistance?
Processing ADC conversion result: DMA vs Processor Registers
Is it appropriate to mention a relatable company blog post when you're asked about the company?
What is the numbering system used for the DSN dishes?
RIP Packet Format
What does the black goddess statue do and what is it?
Will I be more secure with my own router behind my ISP's router?
Magento2 Custom Media Image Attribute do not work in Frontend
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30 pm US/Eastern)
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?Extending the complexType named “imageType” with a custom image typeREST API creating more than one media entry for productGetting a custom attribute imageSwatch attribute ImageMagento2 Product import (image filenames)Media image attribute bugged in frontendMagento 2 get cached url full path of custom attributeGet product image by its “Role” in the galleryNeed to import product image from Media library while updating product imagesMagento 2 model for adding images to media folder (not for products)?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
i have a problem by getting a custom image in the frontend.
- I have a custom media product attribute "image_productlist"
- In my product import i fill the mediaGallery like this:
$oTargetProduct->addImageToMediaGallery($aMediaData['overview_image'], ['image_productlist', 'swatch_image'], false, true);
$oTargetProduct->save();
Where $aMediaData['overview_image'] has the MEDIA IMPORT PATH AND THE FILENAME!
After the import i see in my Admin Backend this image in the gallery and the flags 'image_productlist', 'swatch_image' marked at this image.
Now i want to get this image with flag: 'image_productlist' in my frontend block.
For this i do something like this:
// get the variant images
$existingMediaGalleryEntries = $_simpleProduct->getMediaGalleryEntries();
foreach ($existingMediaGalleryEntries as $key => $entry)
var_dump($entry->getData());
I get this list of the images in the gallery but there is no FLAG 'image_productlist'.
What is wrong??
Thanks for help.
magento2
add a comment |
i have a problem by getting a custom image in the frontend.
- I have a custom media product attribute "image_productlist"
- In my product import i fill the mediaGallery like this:
$oTargetProduct->addImageToMediaGallery($aMediaData['overview_image'], ['image_productlist', 'swatch_image'], false, true);
$oTargetProduct->save();
Where $aMediaData['overview_image'] has the MEDIA IMPORT PATH AND THE FILENAME!
After the import i see in my Admin Backend this image in the gallery and the flags 'image_productlist', 'swatch_image' marked at this image.
Now i want to get this image with flag: 'image_productlist' in my frontend block.
For this i do something like this:
// get the variant images
$existingMediaGalleryEntries = $_simpleProduct->getMediaGalleryEntries();
foreach ($existingMediaGalleryEntries as $key => $entry)
var_dump($entry->getData());
I get this list of the images in the gallery but there is no FLAG 'image_productlist'.
What is wrong??
Thanks for help.
magento2
I think that if you want to retrieve a custom image type, you should retrieve product custom attribute directly. I need to do the same stuff. I keep you updated.
– Franck Garnier
Nov 14 '16 at 9:42
add a comment |
i have a problem by getting a custom image in the frontend.
- I have a custom media product attribute "image_productlist"
- In my product import i fill the mediaGallery like this:
$oTargetProduct->addImageToMediaGallery($aMediaData['overview_image'], ['image_productlist', 'swatch_image'], false, true);
$oTargetProduct->save();
Where $aMediaData['overview_image'] has the MEDIA IMPORT PATH AND THE FILENAME!
After the import i see in my Admin Backend this image in the gallery and the flags 'image_productlist', 'swatch_image' marked at this image.
Now i want to get this image with flag: 'image_productlist' in my frontend block.
For this i do something like this:
// get the variant images
$existingMediaGalleryEntries = $_simpleProduct->getMediaGalleryEntries();
foreach ($existingMediaGalleryEntries as $key => $entry)
var_dump($entry->getData());
I get this list of the images in the gallery but there is no FLAG 'image_productlist'.
What is wrong??
Thanks for help.
magento2
i have a problem by getting a custom image in the frontend.
- I have a custom media product attribute "image_productlist"
- In my product import i fill the mediaGallery like this:
$oTargetProduct->addImageToMediaGallery($aMediaData['overview_image'], ['image_productlist', 'swatch_image'], false, true);
$oTargetProduct->save();
Where $aMediaData['overview_image'] has the MEDIA IMPORT PATH AND THE FILENAME!
After the import i see in my Admin Backend this image in the gallery and the flags 'image_productlist', 'swatch_image' marked at this image.
Now i want to get this image with flag: 'image_productlist' in my frontend block.
For this i do something like this:
// get the variant images
$existingMediaGalleryEntries = $_simpleProduct->getMediaGalleryEntries();
foreach ($existingMediaGalleryEntries as $key => $entry)
var_dump($entry->getData());
I get this list of the images in the gallery but there is no FLAG 'image_productlist'.
What is wrong??
Thanks for help.
magento2
magento2
asked Nov 12 '16 at 12:38
Andre BubnerAndre Bubner
19414
19414
I think that if you want to retrieve a custom image type, you should retrieve product custom attribute directly. I need to do the same stuff. I keep you updated.
– Franck Garnier
Nov 14 '16 at 9:42
add a comment |
I think that if you want to retrieve a custom image type, you should retrieve product custom attribute directly. I need to do the same stuff. I keep you updated.
– Franck Garnier
Nov 14 '16 at 9:42
I think that if you want to retrieve a custom image type, you should retrieve product custom attribute directly. I need to do the same stuff. I keep you updated.
– Franck Garnier
Nov 14 '16 at 9:42
I think that if you want to retrieve a custom image type, you should retrieve product custom attribute directly. I need to do the same stuff. I keep you updated.
– Franck Garnier
Nov 14 '16 at 9:42
add a comment |
2 Answers
2
active
oldest
votes
Make sure the attribute is setup correctly and that the attribute setting Used in product listing
is set to Yes
under Storefront Properties. Then you can get a custom product image attribute by:
$imageHelper = $this->helper('MagentoCatalogHelperImage');
$attributeImage = $_product->getCustomAttribute('image_productlist');
$attributeImageUrl = $imageHelper->init($_product, 'image_productlist')->setImageFile($attributeImage->getValue())->getUrl();
add a comment |
On way to achieve it :
Update the app/design/frontend/VendorName/ThemeName/etc/view.xml of your theme :
<image id="product_custom_image" type="image_productlist">
<width>265</width>
<height>265</height>
</image>
You need to update the default configuration file view.xsd as described in this post with a plugin: Extending the complexType named "imageType" with a custom image type
Then use the default image helper function in order to retrieve your image type such as :
/**
* @var MagentoCatalogHelperImageFactory
*/
protected $helperFactory;
$image = $this->helperFactory->create()->init($product, 'product_custom_image')
->constrainOnly(true)
->keepAspectRatio(true)
->keepTransparency(true)
->keepFrame(false)
->resize(200, 300);
$imageUrl = $image->getUrl();
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
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%2fmagento.stackexchange.com%2fquestions%2f145449%2fmagento2-custom-media-image-attribute-do-not-work-in-frontend%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Make sure the attribute is setup correctly and that the attribute setting Used in product listing
is set to Yes
under Storefront Properties. Then you can get a custom product image attribute by:
$imageHelper = $this->helper('MagentoCatalogHelperImage');
$attributeImage = $_product->getCustomAttribute('image_productlist');
$attributeImageUrl = $imageHelper->init($_product, 'image_productlist')->setImageFile($attributeImage->getValue())->getUrl();
add a comment |
Make sure the attribute is setup correctly and that the attribute setting Used in product listing
is set to Yes
under Storefront Properties. Then you can get a custom product image attribute by:
$imageHelper = $this->helper('MagentoCatalogHelperImage');
$attributeImage = $_product->getCustomAttribute('image_productlist');
$attributeImageUrl = $imageHelper->init($_product, 'image_productlist')->setImageFile($attributeImage->getValue())->getUrl();
add a comment |
Make sure the attribute is setup correctly and that the attribute setting Used in product listing
is set to Yes
under Storefront Properties. Then you can get a custom product image attribute by:
$imageHelper = $this->helper('MagentoCatalogHelperImage');
$attributeImage = $_product->getCustomAttribute('image_productlist');
$attributeImageUrl = $imageHelper->init($_product, 'image_productlist')->setImageFile($attributeImage->getValue())->getUrl();
Make sure the attribute is setup correctly and that the attribute setting Used in product listing
is set to Yes
under Storefront Properties. Then you can get a custom product image attribute by:
$imageHelper = $this->helper('MagentoCatalogHelperImage');
$attributeImage = $_product->getCustomAttribute('image_productlist');
$attributeImageUrl = $imageHelper->init($_product, 'image_productlist')->setImageFile($attributeImage->getValue())->getUrl();
answered Nov 12 '16 at 14:43
oscarpasoscarpas
6501310
6501310
add a comment |
add a comment |
On way to achieve it :
Update the app/design/frontend/VendorName/ThemeName/etc/view.xml of your theme :
<image id="product_custom_image" type="image_productlist">
<width>265</width>
<height>265</height>
</image>
You need to update the default configuration file view.xsd as described in this post with a plugin: Extending the complexType named "imageType" with a custom image type
Then use the default image helper function in order to retrieve your image type such as :
/**
* @var MagentoCatalogHelperImageFactory
*/
protected $helperFactory;
$image = $this->helperFactory->create()->init($product, 'product_custom_image')
->constrainOnly(true)
->keepAspectRatio(true)
->keepTransparency(true)
->keepFrame(false)
->resize(200, 300);
$imageUrl = $image->getUrl();
add a comment |
On way to achieve it :
Update the app/design/frontend/VendorName/ThemeName/etc/view.xml of your theme :
<image id="product_custom_image" type="image_productlist">
<width>265</width>
<height>265</height>
</image>
You need to update the default configuration file view.xsd as described in this post with a plugin: Extending the complexType named "imageType" with a custom image type
Then use the default image helper function in order to retrieve your image type such as :
/**
* @var MagentoCatalogHelperImageFactory
*/
protected $helperFactory;
$image = $this->helperFactory->create()->init($product, 'product_custom_image')
->constrainOnly(true)
->keepAspectRatio(true)
->keepTransparency(true)
->keepFrame(false)
->resize(200, 300);
$imageUrl = $image->getUrl();
add a comment |
On way to achieve it :
Update the app/design/frontend/VendorName/ThemeName/etc/view.xml of your theme :
<image id="product_custom_image" type="image_productlist">
<width>265</width>
<height>265</height>
</image>
You need to update the default configuration file view.xsd as described in this post with a plugin: Extending the complexType named "imageType" with a custom image type
Then use the default image helper function in order to retrieve your image type such as :
/**
* @var MagentoCatalogHelperImageFactory
*/
protected $helperFactory;
$image = $this->helperFactory->create()->init($product, 'product_custom_image')
->constrainOnly(true)
->keepAspectRatio(true)
->keepTransparency(true)
->keepFrame(false)
->resize(200, 300);
$imageUrl = $image->getUrl();
On way to achieve it :
Update the app/design/frontend/VendorName/ThemeName/etc/view.xml of your theme :
<image id="product_custom_image" type="image_productlist">
<width>265</width>
<height>265</height>
</image>
You need to update the default configuration file view.xsd as described in this post with a plugin: Extending the complexType named "imageType" with a custom image type
Then use the default image helper function in order to retrieve your image type such as :
/**
* @var MagentoCatalogHelperImageFactory
*/
protected $helperFactory;
$image = $this->helperFactory->create()->init($product, 'product_custom_image')
->constrainOnly(true)
->keepAspectRatio(true)
->keepTransparency(true)
->keepFrame(false)
->resize(200, 300);
$imageUrl = $image->getUrl();
edited Apr 13 '17 at 12:54
Community♦
1
1
answered Nov 14 '16 at 10:00
Franck GarnierFranck Garnier
2,096926
2,096926
add a comment |
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- 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%2fmagento.stackexchange.com%2fquestions%2f145449%2fmagento2-custom-media-image-attribute-do-not-work-in-frontend%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
I think that if you want to retrieve a custom image type, you should retrieve product custom attribute directly. I need to do the same stuff. I keep you updated.
– Franck Garnier
Nov 14 '16 at 9:42