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;
if($file->Type == 'photo') {
$filePreview->FieldList()->insertBefore(new TextField(
$fields->insertBefore(new TextField(
'AltText',
_t('HtmlEditorField.IMAGEALTTEXT', 'Alternative text (alt) - shown if image cannot be displayed'),
$file->Title,
80
), 'CaptionText');
$filePreview->FieldList()->insertBefore(new TextField(
$fields->insertBefore(new TextField(
'Title',
_t('HtmlEditorField.IMAGETITLE', 'Title text (tooltip) - for additional information about the image')
), 'CaptionText');

View File

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