WordPress.org

Make WordPress Core

Opened 8 years ago

Closed 5 years ago

Last modified 5 years ago

#19181 closed enhancement (worksforme)

Make image_link_input_fields filterable to add buttons

Reported by: ryanimel Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.7
Component: Media Keywords:
Focuses: Cc:
PR Number:

Description

This patch makes the image_link_input_fields function filterable, so that additional buttons could be added to the Link URL section when inserting an image into a post.

In my case, I want to be able to link an image to the post it belongs to. It's a weird/tiny use case, but this filter will let me use a plugin to add it myself.

Attachments (3)

imagelinkfilter.diff (1.2 KB) - added by ryanimel 8 years ago.
media.php (69.6 KB) - added by ryanimel 7 years ago.
Refreshed and improved version of earlier patch.
imagelinkfilter_refresh.diff (1.5 KB) - added by ryanimel 7 years ago.
(Sigh. Best if I upload the patch and not the file it applies to, eh?)

Download all attachments as: .zip

Change History (11)

#1 @ryanimel
8 years ago

If it helps, this is the kind of plugin I have in mind to use once this patch is introduced: http://cl.ly/2s392s1v2B2Y051A1h1x

#2 @nacin
8 years ago

Rather than a general filter on HTML output, we may wish to make an associative array of the type=button's, then filter that, then echo it.

Should be noted the patch is stale thanks to #13544. Seriously. ;)

#3 @ryanimel
7 years ago

Figured I would revisit this ticket and idea. Attaching a refreshed patch with the array of buttons filtered. How's it look?

@ryanimel
7 years ago

Refreshed and improved version of earlier patch.

#4 @helenyhou
7 years ago

Could probably just return that HTML input concatenated with the imploded content of the array and maintain the new lines, rather than storing in the $output variable without them. I'm sure someone else will correct me if that's not the usual style, though :)

#5 @ryanimel
7 years ago

Good call. Updated the patch. Thanks :)

@ryanimel
7 years ago

(Sigh. Best if I upload the patch and not the file it applies to, eh?)

#6 @ericlewis
5 years ago

  • Keywords has-patch removed

At this point the media iframe is deprecated (in spirit if not officially) in lieu of 3.5's media modal.

In the new media experience, users can select "Custom URL" in the "Link to" dropdown, so that solves your use case @ryanimel, perhaps in a rough around the edges sort of way.

Closing out.

#7 @ericlewis
5 years ago

  • Resolution set to worksforme
  • Status changed from new to closed

#8 @SergeyBiryukov
5 years ago

  • Milestone Awaiting Review deleted

This patch makes the image_link_input_fields function filterable, so that additional buttons could be added to the Link URL section when inserting an image into a post.

You could actually add buttons to the old media modal using attachment_fields_to_edit filter, see an example plugin on #21114: add-link-to-large-image.php:ticket:21114.

Note: See TracTickets for help on using tickets.