Merge pull request #2731 from chillu/pulls/2723-embed-images-alt

"alt" and "title" attrs for images from URLs (fixes #2723)
This commit is contained in:
Will Rossiter 2013-12-20 00:19:35 -08:00
commit 5f86a69fdf
2 changed files with 7 additions and 3 deletions

View File

@ -594,13 +594,13 @@ class HtmlEditorField_Toolbar extends RequestHandler {
$urlField->dontEscape = true; $urlField->dontEscape = true;
if($file->Type == 'photo') { if($file->Type == 'photo') {
$filePreview->FieldList()->insertBefore(new TextField( $fields->insertBefore(new TextField(
'AltText', 'AltText',
_t('HtmlEditorField.IMAGEALTTEXT', 'Alternative text (alt) - shown if image cannot be displayed'), _t('HtmlEditorField.IMAGEALTTEXT', 'Alternative text (alt) - shown if image cannot be displayed'),
$file->Title, $file->Title,
80 80
), 'CaptionText'); ), 'CaptionText');
$filePreview->FieldList()->insertBefore(new TextField( $fields->insertBefore(new TextField(
'Title', 'Title',
_t('HtmlEditorField.IMAGETITLE', 'Title text (tooltip) - for additional information about the image') _t('HtmlEditorField.IMAGETITLE', 'Title text (tooltip) - for additional information about the image')
), 'CaptionText'); ), 'CaptionText');

View File

@ -1226,7 +1226,9 @@ ss.editorWrappers['default'] = ss.editorWrappers.tinyMCE;
'src' : this.find('.thumbnail-preview').attr('src'), 'src' : this.find('.thumbnail-preview').attr('src'),
'width' : width ? parseInt(width, 10) : null, 'width' : width ? parseInt(width, 10) : null,
'height' : height ? parseInt(height, 10) : null, 'height' : height ? parseInt(height, 10) : null,
'class' : this.find(':input[name=CSSClass]').val() 'class' : this.find(':input[name=CSSClass]').val(),
'alt' : this.find(':input[name=AltText]').val(),
'title' : this.find(':input[name=Title]').val()
}; };
}, },
getExtraData: function() { getExtraData: function() {
@ -1260,6 +1262,8 @@ ss.editorWrappers['default'] = ss.editorWrappers.tinyMCE;
return $('<div />').append(el).html(); // Little hack to get outerHTML string return $('<div />').append(el).html(); // Little hack to get outerHTML string
}, },
updateFromNode: function(node) { updateFromNode: function(node) {
this.find(':input[name=AltText]').val(node.attr('alt'));
this.find(':input[name=Title]').val(node.attr('title'));
this.find(':input[name=Width]').val(node.width()); this.find(':input[name=Width]').val(node.width());
this.find(':input[name=Height]').val(node.height()); this.find(':input[name=Height]').val(node.height());
this.find(':input[name=Title]').val(node.attr('title')); this.find(':input[name=Title]').val(node.attr('title'));