Download & Extend

Alt text doesn't work from wysiwyg

Project:Media
Version:7.x-1.0-rc2
Component:WYSIWYG integration
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (duplicate)

Issue Summary

The patch at #917212: When using a rich text editor, it is not possible to add an image and save the node using Firefox 3.6 - 4.0. has introduced some issues.

1. The alt text does't get inserted in the editor.

The problem is in this part of the code:

  addImageAttributes: function (imgElement, fid, view_mode, additional) {
    //    imgElement.attr('fid', fid);
    //    imgElement.attr('view_mode', view_mode);
    // Class so we can find this image later.
    imgElement.addClass('media-image');
    this.forceAttributesIntoClass(imgElement, fid, view_mode, additional);
    if (additional) {
      for (k in additional) {
        if (additional.hasOwnProperty(k)) {   <----
          if (k === 'attr') {                 <---- Removing these conditions makes the alt text work again. But I'm not sure what they are for.
            imgElement.attr(k, additional[k]);
          }
        }
      }
    }
  },

2. Additional atributes with spaces in their value get cut.

The hack for putting the attributes values as classes has a flaw, if any of those values has spaces, the final value for that attribute inserted in the tag will contain only the first word. The rest of the words will be kept as classes.

For example, if I use hook_media_format_form_prepare_alter for adding a Caption field, and I insert an image with the caption value as "word1 word2 word3", the final media tag inserted contains:

..."attributes":{"alt":"","caption":"word1","class":"media-image word2 word3",

Comments

#1

Maybe a duplicate of #1307054: Media browser missing image alt and title fields.
(the patch in #7 modify the same line)

#2

Status:active» closed (duplicate)

Marking as a duplicate of #1307054: Media browser missing image alt and title fields