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

Grendel Contents Story Scholarship Depictions Notes References Navigation menu10.1093/notesj/gjn112Berserkeree

Log in Navigation menu

Invalid response line returned from server: HTTP/2 401 | ErrorPlease Please Help With Error 500 Internal Server Error after upgrading from 1.7 to 1.9Unable to place new customer orders in admin backendMagento - For “Manage Categories” Forbidden You do not have permission to access this documentHTTP ERROR 500 when using require(_once) app/Mage.phpMemcached causing Web Setup Wizard ErrorCould not create an acl object: Invalid XMLAn error occurred on the server. Please try to place the order againInvalid response line returned from server: HTTP/2 200 - message after update to 2.1.7Magento-CE 2.3.0 installation error on XamppMagento 2.2.6- After Migration all default Payment Methods are not working fine