[wp-trac] [WordPress Trac] #24518: wp_delete_attachment() does not delete all the intermediate image sizes on some conditions

WordPress Trac noreply at wordpress.org
Thu Jun 6 12:58:17 UTC 2013


#24518: wp_delete_attachment() does not delete all the intermediate image sizes on
some conditions
----------------------------+-----------------------------
 Reporter:  JoshuaAbenazer  |      Owner:
     Type:  defect (bug)    |     Status:  new
 Priority:  normal          |  Milestone:  Awaiting Review
Component:  Media           |    Version:  3.5.1
 Severity:  normal          |   Keywords:  has-patch
----------------------------+-----------------------------
 '''Functionality'''
 The `wp_delete_attachment()` function relies on the
 `get_intermediate_image_sizes()` function which in turn depends on the
 `global $_wp_additional_image_sizes` to delete the intermediate image
 sizes. The `global $_wp_additional_image_sizes` is filled with additional
 images sizes through the `add_image_size()` function, either through
 themes or plugins.



 ''' Steps to reproduce the bug '''
 Now consider the following scenario. We have installed a plugin or theme
 that makes use of `add_image_size()` to add an intermediate image. Suppose
 after using the plugin or theme after few days or months we decide to stop
 using it for some reason. Now what happens is the particular
 `add_image_size()` that was called by the plugin or theme does not exist
 anymore. Now I delete a particular media image that was uploaded when the
 particular theme or plugin was activated. The attachment gets deleted but
 that one particular size remains in the file system since it wasn't
 recognized by the `global $_wp_additional_image_sizes`


 '''Solution'''
 Instead of relying on the `get_intermediate_image_sizes()` function or
 `global $_wp_additional_image_sizes` we could just loop through sizes
 available in the `_wp_attachment_metadata` postmeta (
 `wp_get_attachment_metadata()` )

--
Ticket URL: <http://core.trac.wordpress.org/ticket/24518>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list