WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 18 months ago

#42745 closed enhancement (fixed)

Pass $attachment_id to intermediate_image_sizes_advanced filter

Reported by: robbie505 Owned by: johnbillion
Milestone: 5.1 Priority: normal
Severity: normal Version: 2.9
Component: Media Keywords:
Focuses: Cc:

Description

I'm requesting that the following patch be added, which simply passes the $attachment_id of the image to be used for the new post thumbnail sizes to the intermediate_image_sizes_advanced filter in the wp_generate_attachment_metadata function.

The purpose of this is for unsetting intermediate sizes based on conditions for specific images. For example, I have a need for creating large private galleries with thumbnails-only. So to save hosting storage, I could unset several image-sizes in the $sizes array, depending on a post_meta of the $attachment_id.

Attachments (4)

42745.diff (750 bytes) - added by drywallbmb 3 years ago.
42745.2.diff (742 bytes) - added by drywallbmb 3 years ago.
42745.3.diff (874 bytes) - added by drywallbmb 3 years ago.
42745.4.diff (876 bytes) - added by drywallbmb 3 years ago.

Download all attachments as: .zip

Change History (24)

#1 @robbie505
3 years ago

  • Type changed from defect (bug) to enhancement

#2 @johnbillion
3 years ago

  • Keywords needs-patch good-first-bug added

Thanks for the ticket, @robbie505, and welcome to WordPress Trac.

If you're interested in [submitting a patch https://make.wordpress.org/core/handbook/tutorials/trac/submitting-a-patch/], that would be a big help!

@drywallbmb
3 years ago

#3 @drywallbmb
3 years ago

Is the diff I just added what you were hoping for, @robbie505 ?

@drywallbmb
3 years ago

#4 @drywallbmb
3 years ago

Oops, that first patch was generated by git without the --no-prefix flag so it won't play nicely with SVN. Uploaded a new patch that should work better. Sorry!

#5 @robbie505
3 years ago

Yes @drywallbmb that’s exactly what I was looking for!

I’m new to this.. Where do we go from here?

#6 @drywallbmb
3 years ago

@robbie505 Not sure, TBH. I've developed a bunch of plugins but never contributed to core and thought this ticket would be a reasonable entry point. I think now someone like @johnbillion gets to weigh in...?

#7 @johnbillion
3 years ago

  • Milestone changed from Awaiting Review to 5.0
  • Owner set to johnbillion
  • Status changed from new to reviewing

@drywallbmb Patch looks good! The only thing that needs adding is a @since entry for the parameter. Example: https://core.trac.wordpress.org/browser/tags/4.9.1/src/wp-admin/includes/media.php?marks=2915#L2907

@drywallbmb
3 years ago

#8 @drywallbmb
3 years ago

@johnbillion Oh bother! Thanks for catching that.

New patch provided, though I'm not 100% sure I did it right. Specifically, I'm not sure if I should have done 5.0, 5.0.0, or some magic string that will get auto-populated with the release version when it's finally committed to core.

#9 @drywallbmb
3 years ago

Closer look at existing codebase leads me to the conclusion it should read 5.0.0, updating the patch to reflect that.

@drywallbmb
3 years ago

#10 @robbie505
3 years ago

@drywallbmb I noticed other entry's like 3.0.0.
And I bet it needs to be static.

#11 @johnbillion
3 years ago

  • Component changed from Post Thumbnails to Media

#12 @johnbillion
3 years ago

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

Fixed in [42407].

#13 @johnbillion
21 months ago

  • Keywords good-first-bug removed
  • Milestone changed from 5.0 to 5.0.1
  • Resolution fixed deleted
  • Status changed from closed to reopened

#14 @pento
19 months ago

  • Milestone changed from 5.0.1 to 5.0.2

#15 @pento
19 months ago

  • Milestone changed from 5.0.2 to 5.0.3

#16 @audrasjb
18 months ago

Hello,

@johnbillion you closed the ticket as fixed in [42407] (which seems to be right) and you reopened it later. I can't figure why but there is probably a good reason :) What is needed to see this ticket land in 5.0.3?

#17 @johnbillion
18 months ago

This was fixed in trunk but didn't make it into 5.0. It should be able to go into a minor release soon.

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


18 months ago

#19 @desrosj
18 months ago

  • Keywords needs-patch removed
  • Milestone changed from 5.0.3 to 5.1

This one needs a since update. With 5.1 right around the corner, let's leave it out of 5.0.3 since it is not a regression or block editor related fix.

#20 @desrosj
18 months ago

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

In 44385:

Docs: Update since tag for new intermediate_image_sizes_advanced filter parameter.

Originally added in [42407].

Fixes #42745.

Note: See TracTickets for help on using tickets.