Make WordPress Core

Opened 11 years ago

Closed 11 years ago

Last modified 10 years ago

#32363 closed enhancement (fixed)

Filter in `wp_get_attachment_image_src`

Reported by: eclev91's profile eclev91 Owned by: drewapicture's profile DrewAPicture
Milestone: 4.3 Priority: normal
Severity: normal Version: 2.5
Component: Media Keywords: has-patch dev-feedback
Focuses: Cc:

Description

I’ve been working on a plugin for filler images on posts without thumbnails so that during development I’m not swamping the media library with things I have to delete later.

I can hook into post_thumbnail_html and check if the HTML is empty, which does the trick for things like get_post_thumbnail(), but sometimes I may use the post thumbnail as a background image, so I use wp_get_attachment_image_src instead, which doesn't call the aforementioned hook. It’d be nice to be able to hook in there as well. Other suggestions would be great, but I'll be working on a patch.

Attachments (6)

32363.patch (433 bytes) - added by eclev91 11 years ago.
32363.2.patch (1.6 KB) - added by eclev91 11 years ago.
Run filter on return no matter what
32363.3.patch (1.5 KB) - added by eclev91 11 years ago.
Syntax error resolved, tested with use case
32363.4.patch (2.0 KB) - added by eclev91 11 years ago.
Added docblock, changed name of filter
32363.5.diff (2.1 KB) - added by MikeHansenMe 11 years ago.
fixes some code sniffer errors
32363.diff (1.4 KB) - added by DrewAPicture 11 years ago.
Docs + rename to wp_get_attachment_image_src

Download all attachments as: .zip

Change History (22)

@eclev91
11 years ago

#1 @eclev91
11 years ago

  • Keywords needs-testing added

#2 @eclev91
11 years ago

  • Keywords has-patch added

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


11 years ago

@eclev91
11 years ago

Run filter on return no matter what

@eclev91
11 years ago

Syntax error resolved, tested with use case

#4 @eclev91
11 years ago

  • Keywords needs-testing removed

#5 @johnbillion
11 years ago

  • Component changed from General to Media
  • Keywords needs-docs needs-testing added
  • Milestone changed from Awaiting Review to 4.3
  • Version changed from trunk to 2.5

This'll need a hook docblock and probably a better name for the filter. attachment_image_src is probably most appropriate.

@eclev91
11 years ago

Added docblock, changed name of filter

@MikeHansenMe
11 years ago

fixes some code sniffer errors

#6 @samuelsidler
11 years ago

  • Keywords needs-docs removed

#7 @obenland
11 years ago

  • Owner set to johnbillion
  • Status changed from new to assigned

@johnbillion, do you have time to get it in before beta?

Last edited 11 years ago by obenland (previous) (diff)

#8 @wonderboymusic
11 years ago

  • Keywords needs-testing removed
  • Owner changed from johnbillion to wonderboymusic

#9 @wonderboymusic
11 years ago

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

In 32866:

Add a filter in wp_get_attachment_image_src() called attachment_image_src.

Props eclev91, MikeHansenMe.
Fixes #32363.

@DrewAPicture
11 years ago

Docs + rename to wp_get_attachment_image_src

#10 @DrewAPicture
11 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

Since we're filtering the actual return of wp_get_attachment_image_src(), I think we should name the filter the same thing. In 32363.diff I've adjusted the name and fixed the spacing within the DocBlock.

#11 @johnbillion
11 years ago

  • Keywords dev-feedback added

I don't think the filter name needs to be tied to the function name. The filter is for the attachment image source, so attachment_image_src makes sense.

Doc changes look good.

#12 @wonderboymusic
11 years ago

In 32949:

After [32866], fix doc blocks.

Props DrewAPicture.
See #32363.

#13 @wonderboymusic
11 years ago

  • Owner changed from wonderboymusic to DrewAPicture
  • Status changed from reopened to assigned

The only thing left is (potential) name change of the filter. Up to you.

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


11 years ago

#15 @obenland
11 years ago

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

In 33018:

After [32866], change filter name.

While filter names generally don't have to be tied to the function in which they
are applied, the API for media display generally seems to use the
wp_get_attachment_* pattern.

Props DrewAPicture.
Fixes #32363.

#16 @swissspidy
10 years ago

#29702 was marked as a duplicate.

Note: See TracTickets for help on using tickets.