I am trying to add a custom Alignment field to media inserts. I added the field with a hook_form_alter(), and the field appeared. I was able to insert the media, and everything saved in the database, but the image did not get the appropriate attribute in the WYSIWYG. When I saved the node and viewed it, it had the attribute. It also had the attribute in the WYSIWYG when I edited the node.
The culprit turned out to be in addImageAttributes in wysiwyg-media.js where addImageAttributes is processing the additional object. The code from line 84 is:
for (k in additional) {
if (additional.hasOwnProperty(k)) {
if (k === 'attr') {
imgElement.attr(k, additional[k]);
}
}
}
The if (k === 'attr') statement doesn't make sense because k will never === 'attr'. I got rid of that if statement, and it worked as expected:
for (k in additional) {
if (additional.hasOwnProperty(k)) {
imgElement.attr(k, additional[k]);
}
}
Am I overlooking something? If not, I would be happy to create a patch.
Comments
Comment #0.0
jlyon CreditAttribution: jlyon commentedfixed code
Comment #1
mpgeek CreditAttribution: mpgeek commentedComment #2
mpgeek CreditAttribution: mpgeek commentedComment #2.0
mpgeek CreditAttribution: mpgeek commentedfixed explanation
Comment #3
Chris Matthews CreditAttribution: Chris Matthews as a volunteer commentedClosing this issue as outdated. However, if you think this issue is still important, please let us know and we will gladly re-open it for review.
sincerely,
- the Drupal Media Team