Make WordPress Core

Opened 10 years ago

Closed 10 years ago

Last modified 5 years ago

#33214 closed enhancement (fixed)

Allow media file size to be set from metadata when viewing media modal

Reported by: polevaultweb's profile polevaultweb Owned by: wonderboymusic's profile wonderboymusic
Milestone: 4.4 Priority: normal
Severity: normal Version: 3.5
Component: Media Keywords: has-patch needs-testing
Focuses: Cc:

Description

When viewing an attachment in the edit post screen, the file size is either calculated from the actual file, or taken from 'filesize' if set, from wp_get_attachment_metadata(). This alternative to using filesize( $file ); is helpful for image plugins that store the file somewhere else, i.e. it doesn't exist locally.

However, when you view the media in the modal, the file size is only calculated using the local file.

Attachments (1)

33214.diff (727 bytes) - added by polevaultweb 10 years ago.

Download all attachments as: .zip

Change History (7)

@polevaultweb
10 years ago

#1 @polevaultweb
10 years ago

  • Keywords has-patch needs-testing added

This patch unifies the implementation between

/wp-admin/includes/media.php line 2823

and

/wp-includes/media.php line 2765

Last edited 10 years ago by polevaultweb (previous) (diff)

#2 @wonderboymusic
10 years ago

  • Milestone changed from Awaiting Review to 4.4

#3 @wonderboymusic
10 years ago

  • Owner set to wonderboymusic
  • Resolution set to fixed
  • Status changed from new to closed

In 34258:

Media: In wp_prepare_attachment_for_js(), don't call file_exists() and filesize() to retrieve $bytes if the data is already present in $meta. This is how the same code in attachment_submitbox_metadata() already works.

Props polevaultweb.
Fixes #33214.

#4 @drywallbmb
9 years ago

This is great, but is there anywhere in core where the filesize is actually being stored in the metadata? From what I can tell, these queries are always going to turn up nothing and wind up having to actually look at the filesystem to get the file size. In which case, why add this overhead of asking the DB/metadata first?

#5 follow-up: @drywallbmb
9 years ago

Upon further review, it looks as though WP does populate filesize, but only for media types that get processed by the ID3 library. Is that right? Seems odd to do it for some filetypes and not others.

#6 in reply to: ↑ 5 @SergeyBiryukov
5 years ago

Replying to drywallbmb:

Upon further review, it looks as though WP does populate filesize, but only for media types that get processed by the ID3 library. Is that right? Seems odd to do it for some filetypes and not others.

That indeed seems to be the case. Related: comment:8:ticket:47459.

Note: See TracTickets for help on using tickets.