Schogini - Amazon AWS, Magento and Mobile Developers

Magento 2 Enterprise Edition Auto-Thumbnail Generation

Magento Commerce is the leading provider of open omnichannel innovation. Its an open source, cloud-based digital commerce platform and omnichannel solution which empowers merchants to integrate digital and physical shopping experiences. Built for rapid innovation, the platform combines rich, out-of-the-box functionality with powerful business tools. This customizable platform seamlessly integrates with third-party solutions, can be deployed in any environment, and is backed by a vast network of commerce experts ready to help you.

Magento 2.x is structured to support multi-instance cloud architecture - Elastic scalability, high resilience and availability, while still maintaining flexibility in software customization.


Magento generates thumbnail instances on a need to basis to keep the system optimized. This is specifically true where custom thumbnail sizes are concerned. The client has a Magento 2 store on a multi-instance Amazon EC2 environment with backend on a separate instance and the frontend on multiple instances. Hence, when a new product is added or updated, it is not guaranteed that the frontend instances will get them when the end user browses it. This causes the end user to see broken images. The objective of Schogini’s task was to prevent any “Image not found” incidents, especially when new products or product images are uploaded via the admin.

Schogini’s Role:

Understand how the images are stored and thumbnails are generted in Magento 2.x and develop a solution that must take into account that custom Magento modules can have their own thumbnail sizes. Design a system that will ensure that the new images are correctly propogate to the Amazon instances and ultimately to the CDN to prevent the end user from seeing broken images or default placeholder image.

Schogini’s Solution:

  • Develop a “Magento 2.x Thumbnail Generator” command line (CLI) module that will automatically generate product thumbnails, in all sizes, so that its easily propagated to all EC2 instances and picked up by Amazon CDN.
  • This module will be installed on the Magento 2.x admin Amazon EC2 instance.
  • It will go through all the Magento modules that have their own custom thumbnail sizes and automatically generate thumbnails for each size for all the products. Built-in Magento classes will be used to generate these images which ensures that they will be generated in the correct format and will be stored in the correct path.
  • The thumbnail generator will be triggered once a day via CRON.
  • After the generation, a bash script will pickup these images and copy them to the multiple server instances. This ensures that all instances serve the same files and also the CDN will get populated with the correct files.
  • The system also allows the client to manually trigger this whole process in case they want the propagation to the Amazon EC2 & CDN to happen at any other time.

Client Benefit:

The client can now be sure that the end user of the store will never see a broken image when product images are added or updated. This helps the client maintain quality standards which their end users expect from such a brand.


Gayatri S Ajith - CEO/Cloud & DevOps Architect
Gayatri is a certified professional and highly experienced OpenSource eCommerce developer, team lead, and project manager. She is Magento Certified Developer Plus and Magento Certified Solutions Specialist. With over a decade of hands-on development experience in web technologies (LAMP & MEAN), she has a strong technical background with the ability to communicate those technicalities frequently and clearly. Gayatri is comfortable in proposing alternatives when necessary to ensure the client goals are met - always. Currently, she is mastering AngularJS & Ionic while heading the eCommerce division of Schogini.
Know more about the author.


We love to talk to you, all enquires are replied to in under 4 hours.