Display category image in product view gallerygetMediaGallery() how to see which image is thumbnail, small_image, image?Storeviews not showing the same product image after importHow to get the image type in media image collection?CloudZoom Magento integrationMagento 1.x set thumbnail image same as small image for all productsRemove zoom from product image on product details pagehow to exclude some image from product gallery on front endConfigurable Product image swapping with swatch image?Magento 2.2 adding images to product programmatically does not set small_imageReplace Bitmap Product Image with Jpg?

Would a 7805 5 V regulator drain a 9 V battery?

Counterfeit checks were created for my account. How does this type of fraud work?

"Correct me if I'm wrong"

Is there any possible way to get these hearts as Adult Link?

What is the most suitable position for a bishop here?

Why one uses 了 and the other one doesn’t?

Why there is a red color in right side?

Why is it 出差去 and not 去出差?

Justifying Affordable Bespoke Spaceships

How can I ping multiple IP addresses at the same time?

What is the maximum that Player 1 can win?

Are there any individual aliens that have gained superpowers in the Marvel universe?

Examples of protocols that are insecure when run concurrently

reverse a call to mmap()

How to sort human readable size

Bent arrow under a node

The Amazing Sliding Crossword

Kelvin type connection

Are intrusions within a foreign embassy considered an act of war?

Is there a polite way to ask about one's ethnicity?

How can I improve my violin intonation for enharmonic notes?

Scaling an object to change its key

Am I legally required to provide a (GPL licensed) source code even after a project is abandoned?

How did Frodo know where the Bree village was?



Display category image in product view gallery


getMediaGallery() how to see which image is thumbnail, small_image, image?Storeviews not showing the same product image after importHow to get the image type in media image collection?CloudZoom Magento integrationMagento 1.x set thumbnail image same as small image for all productsRemove zoom from product image on product details pagehow to exclude some image from product gallery on front endConfigurable Product image swapping with swatch image?Magento 2.2 adding images to product programmatically does not set small_imageReplace Bitmap Product Image with Jpg?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I want to display the category image as product image.
So I put this code to my Observer:



$product = $this->_registry->registry('current_product');
$product->addImageToMediaGallery('catalog/category/test.png', array('image', 'small_image', 'thumbnail'), false, false);


This doesn't work. But when I save the product:



$product->save();


He saves the images to the product permanently.
But I want to add the image only for this one request.



I tried also to manipulate the Gallery.php and XML, but then the zoom function isn't working anymore.



How can I achieve this?
Thank you










share|improve this question






















  • Why you need to save category image to product. You want to show at gallery section at frontend?

    – Amit Bera
    Jun 11 at 3:48











  • if you want to add images only for one product pass the sku and load the product and then do your work

    – mohith
    Jun 11 at 4:49











  • @Amit It should not save the image, but I dont know another way to add the image.

    – Lars
    Jun 11 at 7:08












  • @mohith what do you mean with „do your work“. I have the product already loaded, but dont know how to add the image without save it permanently.

    – Lars
    Jun 11 at 7:09


















1















I want to display the category image as product image.
So I put this code to my Observer:



$product = $this->_registry->registry('current_product');
$product->addImageToMediaGallery('catalog/category/test.png', array('image', 'small_image', 'thumbnail'), false, false);


This doesn't work. But when I save the product:



$product->save();


He saves the images to the product permanently.
But I want to add the image only for this one request.



I tried also to manipulate the Gallery.php and XML, but then the zoom function isn't working anymore.



How can I achieve this?
Thank you










share|improve this question






















  • Why you need to save category image to product. You want to show at gallery section at frontend?

    – Amit Bera
    Jun 11 at 3:48











  • if you want to add images only for one product pass the sku and load the product and then do your work

    – mohith
    Jun 11 at 4:49











  • @Amit It should not save the image, but I dont know another way to add the image.

    – Lars
    Jun 11 at 7:08












  • @mohith what do you mean with „do your work“. I have the product already loaded, but dont know how to add the image without save it permanently.

    – Lars
    Jun 11 at 7:09














1












1








1








I want to display the category image as product image.
So I put this code to my Observer:



$product = $this->_registry->registry('current_product');
$product->addImageToMediaGallery('catalog/category/test.png', array('image', 'small_image', 'thumbnail'), false, false);


This doesn't work. But when I save the product:



$product->save();


He saves the images to the product permanently.
But I want to add the image only for this one request.



I tried also to manipulate the Gallery.php and XML, but then the zoom function isn't working anymore.



How can I achieve this?
Thank you










share|improve this question














I want to display the category image as product image.
So I put this code to my Observer:



$product = $this->_registry->registry('current_product');
$product->addImageToMediaGallery('catalog/category/test.png', array('image', 'small_image', 'thumbnail'), false, false);


This doesn't work. But when I save the product:



$product->save();


He saves the images to the product permanently.
But I want to add the image only for this one request.



I tried also to manipulate the Gallery.php and XML, but then the zoom function isn't working anymore.



How can I achieve this?
Thank you







magento2.3 product-images






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jun 10 at 21:32









LarsLars

1007




1007












  • Why you need to save category image to product. You want to show at gallery section at frontend?

    – Amit Bera
    Jun 11 at 3:48











  • if you want to add images only for one product pass the sku and load the product and then do your work

    – mohith
    Jun 11 at 4:49











  • @Amit It should not save the image, but I dont know another way to add the image.

    – Lars
    Jun 11 at 7:08












  • @mohith what do you mean with „do your work“. I have the product already loaded, but dont know how to add the image without save it permanently.

    – Lars
    Jun 11 at 7:09


















  • Why you need to save category image to product. You want to show at gallery section at frontend?

    – Amit Bera
    Jun 11 at 3:48











  • if you want to add images only for one product pass the sku and load the product and then do your work

    – mohith
    Jun 11 at 4:49











  • @Amit It should not save the image, but I dont know another way to add the image.

    – Lars
    Jun 11 at 7:08












  • @mohith what do you mean with „do your work“. I have the product already loaded, but dont know how to add the image without save it permanently.

    – Lars
    Jun 11 at 7:09

















Why you need to save category image to product. You want to show at gallery section at frontend?

– Amit Bera
Jun 11 at 3:48





Why you need to save category image to product. You want to show at gallery section at frontend?

– Amit Bera
Jun 11 at 3:48













if you want to add images only for one product pass the sku and load the product and then do your work

– mohith
Jun 11 at 4:49





if you want to add images only for one product pass the sku and load the product and then do your work

– mohith
Jun 11 at 4:49













@Amit It should not save the image, but I dont know another way to add the image.

– Lars
Jun 11 at 7:08






@Amit It should not save the image, but I dont know another way to add the image.

– Lars
Jun 11 at 7:08














@mohith what do you mean with „do your work“. I have the product already loaded, but dont know how to add the image without save it permanently.

– Lars
Jun 11 at 7:09






@mohith what do you mean with „do your work“. I have the product already loaded, but dont know how to add the image without save it permanently.

– Lars
Jun 11 at 7:09











0






active

oldest

votes












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
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f277878%2fdisplay-category-image-in-product-view-gallery%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































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.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f277878%2fdisplay-category-image-in-product-view-gallery%23new-answer', 'question_page');

);

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







Popular posts from this blog

Get product attribute by attribute group code in magento 2get product attribute by product attribute group in magento 2Magento 2 Log Bundle Product Data in List Page?How to get all product attribute of a attribute group of Default attribute set?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 : Get Product Attribute values By GroupMagento 2 How to get all existing values for one attributeMagento 2 get custom attribute of a single product inside a pluginMagento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento2: how to develop rest API to get new productsGet product attribute by attribute group code ( [attribute_group_code] ) in magento 2

Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

Magento 2.3: How do i solve this, Not registered handle, on custom form?How can i rewrite TierPrice Block in Magento2magento 2 captcha not rendering if I override layout xmlmain.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?Magento 2.2.5: Overriding Admin Controller sales/orderMagento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 : File Upload issue in UI Component FormMagento2 Not registered handleHow to configured Form Builder Js in my custom magento 2.3.0 module?Magento 2.3. How to create image upload field in an admin form