0

On edit media screen been trying to have caption fields replaced with title fields for easier titling of images.

Titles would be exactly the same as captions

Successfully have the caption fields replaced with title fields via jQuery. When filling the fields they save the field data to those image titles:

$(document.body).on( 'click', '.media-frame-tab-panel input.describe', function( event ) {
            $(this).attr({
              "data-setting" : "title",
              "placeholder" : "Image Title"
            });
          });
$( ".media-frame-tab-panel input.describe" ).change(function() {
  $(this).attr({
              "data-setting" : "title",
              "placeholder" : "Image Title"
            });
});

Unfortunately when clicking outside the title field it's immediately replaced with a caption field. The change event doesn't detect the change to swap right back. Looked into other solutions here which replace the title with caption and vise versa, but only upon upload instead of upon edit. After spending a great deal of time going through dozens of edit_image hooks I opted for a jQuery route. Stopping propagation is a bad idea due to losing the save action when clicking outside of the field.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.