"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; $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'));