3

How can i change those editing inputs to title from caption? wp3.5 gallery edit

Some sources i found about new upload system:

Basically looking for a proper solution like this:

// http://wordpress.org/support/topic/wp-35-any-way-to-default-add-media-to-upload-files#post-3709109
// If you want to have the editor default to the Upload Files tab in the admin editor
add_action( 'admin_footer-post-new.php', 'idealien_mediaDefault_script' );
add_action( 'admin_footer-post.php', 'idealien_mediaDefault_script' );
function idealien_mediaDefault_script()
{
    ?>
<script type="text/javascript">
jQuery(document).ready(function($){
    wp.media.controller.Library.prototype.defaults.contentUserSetting = false; // making editor default to the Upload Files

});
</script>
<?php } 
6
  • 1
    Have you done any research? What have you tried so far?
    – s_ha_dum
    Commented Feb 20, 2013 at 19:33
  • I spent lots of hours to understand new wp media gallery modal system but it is using backbone.js and most of guides are about creating custom upload buttons, not changing default one. Thanks for -1 btw.. I still believe its a good question Commented Feb 20, 2013 at 19:43
  • If i had any clue on solution for the problem, believe me i would share. Just check my previous questions. I explained solutions when i find it. I simply stucked because wp-admin files still includes previous media uploader codes and "attachment_fields_to_edit" or lots of old filters/actions simply not effecting to new uplaod system. I only found this: mikejolley.com/2012/12/… but its only js and there is no explanation on how to use it Commented Feb 20, 2013 at 20:03
  • Started bounty. Maybe it helps ^^ Commented Feb 23, 2013 at 10:25
  • Don't know if helps, but check this. What I've seen is that all topics related to the new Media Manager were met with silence in [wp-hackers]. I suppose we'll only have proper hooks and documentation around 3.6, if not 3.7 :/
    – brasofilo
    Commented Feb 25, 2013 at 12:08

2 Answers 2

2

You can deactivate the default gallery, the shortcode via hook. Also add a new function for the shortcode gallery and copz, paste from original aand change the input for caption. Put all source in a plugin. If WordPress change this in a next version, then deactivate your plugin or change it. I think it is the best solution without change the input on media manager.

2
  • i updated question. Looking for a solution like adding wp.media.controller.Library.prototype.defaults.contentUserSetting = false; Commented Feb 21, 2013 at 0:08
  • But the title is not the default on the gallery. If you will, that the user can't change this, then hide the parts in the media window and change the shortcode function for gallery, use alwys the title for images inside the gallery.
    – bueltge
    Commented Feb 21, 2013 at 7:52
2

I explained solution here: http://unsalkorkmaz.com/wp3-5-media-gallery-edit-modal-change-captions-to-title/

If you want just solution:

add_action( 'admin_footer-post-new.php', 'firmasite_replace_script_tmpl_attachment' );
add_action( 'admin_footer-post.php', 'firmasite_replace_script_tmpl_attachment' );
function firmasite_replace_script_tmpl_attachment()
{ ?>
    <script type="text/javascript">
        jQuery(document).ready(function($){
            jQuery("script#tmpl-attachment:first").remove();
        });
    </script>
    <script type="text/html" id="tmpl-attachment">
        <div class="attachment-preview type-{{ data.type }} subtype-{{ data.subtype }} {{ data.orientation }}">
            <# if ( data.uploading ) { #>
                <div class="media-progress-bar"><div></div></div>
            <# } else if ( 'image' === data.type ) { #>
                <div class="thumbnail">
                    <div class="centered">
                        <img src="{{ data.size.url }}" draggable="false" />
                    </div>
                </div>
            <# } else { #>
                <img src="{{ data.icon }}" class="icon" draggable="false" />


        <div class="filename">
                <div>{{ data.filename }}</div>
            </div>
        <# } #>

        <# if ( data.buttons.close ) { #>
            <a class="close media-modal-icon" href="#" title="<?php _e('Remove'); ?>"></a>
        <# } #>

        <# if ( data.buttons.check ) { #>
            <a class="check" href="#" title="<?php _e('Deselect'); ?>"><div class="media-modal-icon"></div></a>
        <# } #>
    </div>
    <#
    var maybeReadOnly = data.can.save || data.allowLocalEdits ? '' : 'readonly';
    if ( data.describe ) { #>
        <# if ( 'image' === data.type ) { #>
            <input type="text" value="{{ data.title }}" class="describe" data-setting="title"
                placeholder="<?php esc_attr_e('Caption this image&hellip;'); ?>" {{ maybeReadOnly }} />
        <# } else { #>
            <input type="text" value="{{ data.title }}" class="describe" data-setting="title"
                <# if ( 'video' === data.type ) { #>
                    placeholder="<?php esc_attr_e('Describe this video&hellip;'); ?>"
                <# } else if ( 'audio' === data.type ) { #>
                    placeholder="<?php esc_attr_e('Describe this audio file&hellip;'); ?>"
                <# } else { #>
                    placeholder="<?php esc_attr_e('Describe this media file&hellip;'); ?>"
                <# } #> {{ maybeReadOnly }} />
        <# } #>
    <# } #>
</script>

2
  • Downvote. Thanks for providing a solution, but discussion should have been included here, not linked to with a link which has since died, leaving this answer unexplained.
    – John Smith
    Commented Feb 11 at 3:10
  • 11 years ago... @JohnSmith I am not sure if those codes works or not now. Commented Mar 2 at 20:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.