Make WordPress Core

Opened 7 years ago

Last modified 6 weeks ago

#43413 new defect (bug)

wp_prepare_attachment_for_js missing image size medium_large

Reported by: themezly's profile Themezly Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 4.9.4
Component: Media Keywords: has-patch
Focuses: Cc:

Description

I have a function that creates a media size in case the size is called but is missing in meta. https://gist.github.com/danyj/2edb3d83bae4c363bf839f0dd5f1343f

usage

thz_create_missing_attachment_size(13031,'medium_large');

every missing file size is recreated and exists in by wp_prepare_attachment_for_js size key except the media_large because it is missing here.

https://github.com/WordPress/WordPress/blob/dfa68397063daf90a8758896693f137f9b981856/wp-includes/media.php#L3297-L3304

Basically if meta has been updated the wp_prepare_attachment_for_js is not checking for sizes but manually goes by that array . Not sure if the missing size key is left out on purpose but when you compare the wp_prepare_attachment_for_js to wp_get_attachment_metadata the data is not same

Change History (2)

#1 @joemcgill
6 years ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to Future Release

Hi @Themezly. Thanks for the report!

When this size was originally added in WordPress 4.4 [35479], we intentionally avoided making that size available in public APIs or UI while we waited to see how the new size would affect performance. At this point, I think it's safe to say this is an established size in WP and should be available in APIs.

This ticket was mentioned in PR #7709 on WordPress/wordpress-develop by @debarghyabanerjee.


6 weeks ago
#2

  • Keywords has-patch added; needs-patch removed

Trac Ticket: Core-43413

## Overview

  • This pull request introduces the addition of the medium_large image size to the wp_prepare_attachment_for_js function in WordPress. This enhancement allows for better handling and retrieval of the medium_large image size in the JavaScript context, providing developers with more flexibility when working with media attachments.

## Changes Made

  • Modified the wp_prepare_attachment_for_js function to include the medium_large image size.

Ensured that the new size is appropriately registered and available for use in the media library.

## Benefits

  • Improved Media Management: By including the medium_large size, users can more effectively manage and display images without needing to generate additional sizes manually.
  • Better Performance: Utilizing the appropriate image size can improve page load times and overall performance, particularly on responsive designs where image dimensions are critical.
Note: See TracTickets for help on using tickets.