"alt" and "title" attrs for images from URLs (fixes #2723)

This commit is contained in:
Ingo Schommer 2013-12-19 19:43:46 +01:00
parent ddcdb2c0f0
commit 03b2e9dc74
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'));