Make WordPress Core

Opened 9 years ago

Closed 9 years ago

Last modified 3 years ago

#33011 closed enhancement (fixed)

Uploading a 512 x 512 site icon creates a duplicated image in the media library

Reported by: stuartshields's profile stuartshields Owned by: obenland's profile obenland
Milestone: 4.3 Priority: normal
Severity: normal Version: 4.3
Component: Administration Keywords: has-patch
Focuses: Cc:

Description

When a site icon is uploaded that is 512px x 512px it shouldn't be cropped by the system. The system should see it's the correct size and not duplicate it. The file size is also exactly the same the only difference is now you have a duplicate of the file with copy at the front.

Attachments (3)

Screen Shot 2015-07-16 at 4.49.10 pm.png (120.7 KB) - added by stuartshields 9 years ago.
33011.diff (1.6 KB) - added by obenland 9 years ago.
33011.2.diff (2.4 KB) - added by obenland 9 years ago.

Download all attachments as: .zip

Change History (17)

#1 @netweb
9 years ago

  • Keywords dev-feedback added
  • Milestone changed from Awaiting Review to 4.3
  • Owner set to obenland
  • Status changed from new to assigned
  • Summary changed from Site Icon to Uploading a 512 x 512 site icon creates a duplicated image in the media library

Testing: The original file uploaded was bDkmXyEmr5.png 512 x 512 and the uncropped file is created prefixed with copy- along with the extra thumbnails.

-rw-rw-r--  1 netweb staff  11K Jul 16 16:38 bDkmXyEmr5-150x150.png
-rw-rw-r--  1 netweb staff  27K Jul 16 16:38 bDkmXyEmr5-300x300.png
-rw-rw-r--  1 netweb staff  23K Jul 16 16:38 bDkmXyEmr5-512x270.png
-rw-rw-r--  1 netweb staff  38K Jul 16 16:38 bDkmXyEmr5.png
-rw-rw-r--  1 netweb staff  11K Jul 16 16:38 copy-bDkmXyEmr5-150x150.png
-rw-rw-r--  1 netweb staff  14K Jul 16 16:38 copy-bDkmXyEmr5-180x180.png
-rw-rw-r--  1 netweb staff  15K Jul 16 16:38 copy-bDkmXyEmr5-192x192.png
-rw-rw-r--  1 netweb staff  24K Jul 16 16:38 copy-bDkmXyEmr5-270x270.png
-rw-rw-r--  1 netweb staff  27K Jul 16 16:38 copy-bDkmXyEmr5-300x300.png
-rw-rw-r--  1 netweb staff 1.9K Jul 16 16:38 copy-bDkmXyEmr5-32x32.png
-rw-rw-r--  1 netweb staff  23K Jul 16 16:38 copy-bDkmXyEmr5-512x270.png
-rw-r--r--  1 netweb staff  38K Jul 16 16:38 copy-bDkmXyEmr5.png

Can we not just use the original 512 x 512 file uploaded and generate the extra thumbs needed?

#2 follow-up: @obenland
9 years ago

Did you test it in the Customizer or the Settings version?

I wouldn't be surprised if in the Customizer they duplicate it to not stomp on the original image once it was set as a header/background/site-icon. I'd also have to find out if the media modal passes on whether the file was just uploaded or was pre-existing, so the cause could also be a lack of information.

#3 in reply to: ↑ 2 @netweb
9 years ago

Replying to obenland:

Did you test it in the Customizer or the Settings version?

I originally only tested in the customizer, tested just now via settings, the same results where lego-minifigure-catalog-icon-512.png was the original 512 x 512 file, this just as my previous example above was/is a new file that was not previously in the media library, a fresh upload:

-rw-rw-r--  1 netweb staff  20K Jul 18 07:17 copy-lego-minifigure-catalog-icon-512-150x150.png
-rw-rw-r--  1 netweb staff  25K Jul 18 07:17 copy-lego-minifigure-catalog-icon-512-180x180.png
-rw-rw-r--  1 netweb staff  28K Jul 18 07:17 copy-lego-minifigure-catalog-icon-512-192x192.png
-rw-rw-r--  1 netweb staff  43K Jul 18 07:17 copy-lego-minifigure-catalog-icon-512-270x270.png
-rw-rw-r--  1 netweb staff  50K Jul 18 07:17 copy-lego-minifigure-catalog-icon-512-300x300.png
-rw-rw-r--  1 netweb staff 2.6K Jul 18 07:17 copy-lego-minifigure-catalog-icon-512-32x32.png
-rw-rw-r--  1 netweb staff  39K Jul 18 07:17 copy-lego-minifigure-catalog-icon-512-512x270.png
-rw-r--r--  1 netweb staff  76K Jul 18 07:17 copy-lego-minifigure-catalog-icon-512.png
-rw-rw-r--  1 netweb staff  20K Jul 18 07:17 lego-minifigure-catalog-icon-512-150x150.png
-rw-rw-r--  1 netweb staff  50K Jul 18 07:17 lego-minifigure-catalog-icon-512-300x300.png
-rw-rw-r--  1 netweb staff  39K Jul 18 07:17 lego-minifigure-catalog-icon-512-512x270.png
-rw-rw-r--  1 netweb staff  76K Jul 18 07:17 lego-minifigure-catalog-icon-512.png

Replying to obenland:

I wouldn't be surprised if in the Customizer they duplicate it to not stomp on the original image once it was set as a header/background/site-icon.

Per the above it's not isolated to the customizer.

Replying to obenland:

I'd also have to find out if the media modal passes on whether the file was just uploaded or was pre-existing, so the cause could also be a lack of information.

I think your onto something here, thanks for taking a look :)

#4 @obenland
9 years ago

Any news on this? What would be the expected behavior and why? Where dos Site Icon behave differently from Headers or Backgrounds?

#5 @stuartshields
9 years ago

Hi,

Expect behavior for me is this:

A file that is uploaded at 512x512 shouldn't be duplicated at that size. The reason for this is, it's duplicating a size that already exists.

What would be a nifty little feature is, it ignores the re-sizing of image_size and only creates the site icon sizes.

Does that answer your question?

#6 @netweb
9 years ago

Here's my take with the caveat I've not looked into if this functionality happens in other parts of the media library when uploading files:

Pretty much if I upload a file, per my last example lego-minifigure-catalog-icon-512.png, I'd then expect some thumbnails be generated based on the intended use case of the file I'm uploading, in this case we're wanting some square images, so generate the default base thumbnails, 150x150, 300x300, 512x270, now we need those additional square thumbnails, generate the 32x32, 180x180, 192x192, and 270x270 thumbnails, for a total of 1 original image and 7 thumbnails, totalling 8 images.

Rather than that above, in the current state we have 12 image files, of which 4 are duplicates.

This is the list of files that I would have expected to exist after uploading an image to be used as a site icon:

lego-minifigure-catalog-icon-512.png
lego-minifigure-catalog-icon-512-32x32.png
lego-minifigure-catalog-icon-512-150x150.png
lego-minifigure-catalog-icon-512-300x300.png
lego-minifigure-catalog-icon-512-512x270.png
lego-minifigure-catalog-icon-512-180x180.png
lego-minifigure-catalog-icon-512-192x192.png
lego-minifigure-catalog-icon-512-270x270.png

#7 @obenland
9 years ago

Based on my testing with latest trunk it seems like custom headers make you go through the cropping stage even though the image has the recommended size, resulting in the original image and a cropped version of that image.

For Site Icon that cropping stage is skipped, which results in the custom image sizes not being generated.

#8 @obenland
9 years ago

So I think we'll always have to duplicate the image because we can't be sure whether it was recently uploaded or selected from previously existing images.

@obenland
9 years ago

This ticket was mentioned in Slack in #core by netweb. View the logs.


9 years ago

#10 @netweb
9 years ago

I cannot reproduce this as of r33352

Tested this 3 times just now, twice uploading a new 512x512 and one at 600x600, the larger gets cropped to 512x512 with files prefixed with cropped-, the original 512x512 files are used with no duplicates created of file name changes, works as expected.

Also tested header image behaviour, using a 954x1300 header image for Twenty Fifteen, uploading an exact dimension file then this file is used as is, uploading a larger dimension file the image is cropped and prefixed with cropped-, works as expected.

A changeset overnight that is alluding me has changed the behaviour here per the original report and now everything works as expected for me.

Last edited 9 years ago by netweb (previous) (diff)

@obenland
9 years ago

#11 @obenland
9 years ago

  • Keywords has-patch added; dev-feedback removed

Patch sends attachments that are the exact size back to cropping and uses the same attachment if it has the site-icon context.
This will still duplicate the original image, which we can't change to avoid stomping people's images, but it will not create additional images after that.

#13 @obenland
9 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 33356:

Site Icon: Create custom sizes for images that don't need cropping.

This will duplicate an image that doesn't need cropping once and will skip
creating new images and custom sizes if the selected image has the site-icon
context.

Fixes #33011.

#14 @celloexpressions
3 years ago

#38530 was marked as a duplicate.

Note: See TracTickets for help on using tickets.