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

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

Circuit construction for execution of conditional statements using least significant bitHow are two different registers being used as “control”?How exactly is the stated composite state of the two registers being produced using the $R_zz$ controlled rotations?Efficiently performing controlled rotations in HHLWould this quantum algorithm implementation work?How to prepare a superposed states of odd integers from $1$ to $sqrtN$?Why is this implementation of the order finding algorithm not working?Circuit construction for Hamiltonian simulationHow can I invert the least significant bit of a certain term of a superposed state?Implementing an oracleImplementing a controlled sum operation

Magento 2 “No Payment Methods” in Admin New OrderHow to integrate Paypal Express Checkout with the Magento APIMagento 1.5 - Sales > Order > edit order and shipping methods disappearAuto Invoice Check/Money Order Payment methodAdd more simple payment methods?Shipping methods not showingWhat should I do to change payment methods if changing the configuration has no effects?1.9 - No Payment Methods showing upMy Payment Methods not Showing for downloadable/virtual product when checkout?Magento2 API to access internal payment methodHow to call an existing payment methods in the registration form?