Skip to content

Conversation

@m-michalis
Copy link
Contributor

This is the 2nd PR based on @addison74's #5026 (comment)

Parts:

  • Keep/Skip product images (this pr): Ask whether to keep or skip product images on "Duplicate" + configuration for automating this behavior Media Gallery behavior when duplicating a product: Keep/Skip product images #5083
  • [This PR] Delete product/images: Whether to physically delete images on either when removing images from a product and/or deleting a product + configuration for default behavior.
  • Use new copied images: Copy and actually use copied images on new duplicated product (bug for many years) + propagate store values correctly regarding image, small_image, thumbnail attributes

Description

This PR controls how product image files are handled when a product is deleted or when an image is removed from a product’s media gallery. Depending on the selected behavior, image files may be retained on the filesystem or permanently deleted to prevent orphaned media and reduce storage usage.

  • Configuration at System > Configuration > Catalog > Product Image > Product image file handling on removal
  • Failsafe/Compatibility when image files are referenced by other products due to known bug in duplicate action

…ted or when an image is removed from a product’s media gallery.

- it contains failsafe that prevents unintended removal of shared images used across multiple products.
@github-actions github-actions bot added Component: Catalog Relates to Mage_Catalog Component: Adminhtml Relates to Mage_Adminhtml translations Relates to app/locale labels Jan 10, 2026
@sonarqubecloud
Copy link

<show_in_store>1</show_in_store>
</images_on_duplicate_action>
<images_on_removal_action translate="label comment">
<label>Product image file handling on removal</label>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Delete Product Images Management" is a concise and clear label for managing product images upon deletion. Each word must start with a capital letter as a standard convention in Magento 1 UI/UX design to maintain consistency and readability, especially in settings or configuration sections.

This label will follow the same format as the one above it in the section, 'Duplicate Product Images' – proposed in a PR I opened today.

public function toOptionArray()
{
return [
['value' => Mage_Catalog_Model_Product_Image::ON_REMOVAL_KEEP, 'label' => Mage::helper('adminhtml')->__('Keep image file(s) on the filesystem')],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Keep the images on the filesystem" - is clearer and more straightforward than the initial one. By using "the images", we specify the exact object being referred to, making the options more precise. Removing unnecessary complexity, like the plural indicator "(s)," and using simple, direct language improves readability and ensures better understanding for the user. The word 'file' is omitted because it is understood that images are stored as files on the filesystem, making it unnecessary to repeat 'file' in the label.

{
return [
['value' => Mage_Catalog_Model_Product_Image::ON_REMOVAL_KEEP, 'label' => Mage::helper('adminhtml')->__('Keep image file(s) on the filesystem')],
['value' => Mage_Catalog_Model_Product_Image::ON_REMOVAL_DELETE, 'label' => Mage::helper('adminhtml')->__('Permanently deletes image file(s)')],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Permanently delete the images" - is clearer and more straightforward than the initial one. By using "the images", we specify the exact object being referred to, making the options more precise. Removing unnecessary complexity, like the plural indicator "(s)," and using simple, direct language improves readability and ensures better understanding for the user. The word 'file' is omitted because it is understood that images are stored as files on the filesystem, making it unnecessary to repeat 'file' in the label.

</images_on_duplicate_action>
<images_on_removal_action translate="label comment">
<label>Product image file handling on removal</label>
<comment><![CDATA[Defines how product image files are handled when a product is deleted or when an image is removed from the product media gallery.<br/><br/><strong>Important:</strong> image files referenced by other products will not be deleted. Only image files that are no longer associated with any product are eligible for removal.]]></comment>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modification of the sentences:

1 - "Defines how the product images are managed when a product is deleted or an image is removed from the product media gallery."

2 - "Important! Images used by other products will not be deleted. Only those that are no longer associated with any product can be deleted." - please note the exclamation mark.

3 - Important! must be in red color - here is an example from the existing code

<comment><![CDATA[<strong style="color:red">Important!</strong> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed.]]></comment>

Comment on lines +1324 to +1327
"Product image file handling on removal","Product image file handling on removal"
"Defines how product image files are handled when a product is deleted or when an image is removed from the product media gallery.<br/><br/><strong>Important:</strong> image files referenced by other products will not be deleted. Only image files that are no longer associated with any product are eligible for removal.","Defines how product image files are handled when a product is deleted or when an image is removed from the product media gallery.<br/><br/><strong>Important:</strong> image files referenced by other products will not be deleted. Only image files that are no longer associated with any product are eligible for removal."
"Keep image file(s) on the filesystem","Keep image file(s) on the filesystem"
"Permanently deletes image file(s)","Permanently deletes image file(s)"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These sentences must be changed too.

@addison74
Copy link
Contributor

Except for the texts that are easy to change, this PR is well elaborated and implemented. Thank you @m-michalis for your contribution.

I kindly ask those who have some time available to test and get it ready for 2.17.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Component: Adminhtml Relates to Mage_Adminhtml Component: Catalog Relates to Mage_Catalog translations Relates to app/locale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants