Make WordPress Core

Opened 9 years ago

Last modified 5 years ago

#31614 new enhancement

Add Actions to underscore media-template items

Reported by: andrewgstreet's profile andrewgstreet Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Media Keywords:
Focuses: Cc:

Description

Currently, there is no way to override the underscore templates used in media-template.php. It would great if each template item was preceded by a conditional such that:

   $result = do_action('tmpl-attachment'); //template name as action
   if (isset($result) && $result !== false) {
   ?>

   <script type="text/html" id="tmpl-attachment">
   <!-- Existing Template Here -->
   </script>

   <?php }

Then it would be easy to duplicate the existing template for modification

   function my_custom_media_attachment_template() {
    ?>
    <script type="text/html" id="tmpl-attachment">
        <!-- My Custom Template Goes Here -->
    </script>
    <?php
    return false;
   }
   add_action("tmpl-attachment", my_custom_media_attachment_template);

For my current project I'm having to do it, which of course means hacking the WP core. I'd be happy to share.

Attachments (3)

media-template.php (46.1 KB) - added by andrewgstreet 9 years ago.
Suggested code modifcations
media.php (111.5 KB) - added by andrewgstreet 9 years ago.
Add actions to playlist templates
wp-playlist.js (4.7 KB) - added by andrewgstreet 9 years ago.
Update wp-playlist-tracks to use a template rather than hard coding the html

Download all attachments as: .zip

Change History (7)

@andrewgstreet
9 years ago

Suggested code modifcations

@andrewgstreet
9 years ago

Add actions to playlist templates

@andrewgstreet
9 years ago

Update wp-playlist-tracks to use a template rather than hard coding the html

#1 @iseulde
9 years ago

  • Version trunk deleted

This ticket was mentioned in Slack in #core-images by joemcgill. View the logs.


8 years ago

#3 @joemcgill
8 years ago

Thanks for the ticket @andrewgstreet. I could see how it would be useful to modify the JS templates for embedded media items. I think the approach in #31281 might be a better holistic solution to this problem.

A sidenote: patches should be uploaded as SVN diffs. See this tutorial in the core handbook.

#4 @georgestephanis
8 years ago

Should we close this in favor of / as a duplicate of #31281 ?

Last edited 8 years ago by georgestephanis (previous) (diff)
Note: See TracTickets for help on using tickets.