image css, only set float: left if not img is not in figure

This commit is contained in:
j 2016-06-26 23:59:44 +02:00
parent c5cd5cb8cb
commit 9283f28826
2 changed files with 20 additions and 13 deletions

View file

@ -636,7 +636,7 @@
displayed at the top of the screen. This title can be customized by adding displayed at the top of the screen. This title can be customized by adding
"/static/js/getItemTitle.SITENAME.js". "/static/js/getItemTitle.SITENAME.js".
*/ */
"itemTitleKeys": ["title", "director", "date"], "itemTitleKeys": ["title", "director", "year"],
/* /*
"itemViews" is an ordered list of available item views. Implemented views "itemViews" is an ordered list of available item views. Implemented views
are "info", "documents", "player", "editor", "timeline", "clips", "map", are "info", "documents", "player", "editor", "timeline", "clips", "map",

View file

@ -260,12 +260,7 @@ pandora.ui.infoView = function(data) {
clickLink: pandora.clickLink, clickLink: pandora.clickLink,
collapseToEnd: false, collapseToEnd: false,
editable: canEdit, editable: canEdit,
format: function(value) { format: imageCSS,
return value.replace(
/<img src=/g,
'<img style="max-width: 256px; max-height: 256px; margin: 0 16px 16px 0" src='
);
},
maxHeight: Infinity, maxHeight: Infinity,
placeholder: formatLight(Ox._('No Summary')), placeholder: formatLight(Ox._('No Summary')),
tooltip: canEdit ? pandora.getEditTooltip() : '', tooltip: canEdit ? pandora.getEditTooltip() : '',
@ -326,12 +321,7 @@ pandora.ui.infoView = function(data) {
descriptions[key] = Ox.EditableContent({ descriptions[key] = Ox.EditableContent({
clickLink: pandora.clickLink, clickLink: pandora.clickLink,
editable: canEdit, editable: canEdit,
format: function(value) { format: imageCSS,
return value.replace(
/<img src=/g,
'<img style="float: left; max-width: 256px; max-height: 256px; margin: 0 16px 16px 0" src='
);
},
placeholder: formatLight(Ox._('No {0} Description', [Ox._(Ox.toTitleCase(key))])), placeholder: formatLight(Ox._('No {0} Description', [Ox._(Ox.toTitleCase(key))])),
tooltip: canEdit ? pandora.getEditTooltip() : '', tooltip: canEdit ? pandora.getEditTooltip() : '',
type: 'textarea', type: 'textarea',
@ -694,6 +684,23 @@ pandora.ui.infoView = function(data) {
}); });
} }
function imageCSS(value) {
var $html = $('<div>').html(value);
$html.find('img').each(function(i, img) {
var $img = $(img),
css = {
'max-width': '256px',
'max-height': '256px',
'margin': '0 16px 16px 0'
};
if (!$img.parents('figure').length) {
css['float'] = 'left';
}
$img.css(css);
});
return $html.html();
}
function renderGroup(keys) { function renderGroup(keys) {
var $element; var $element;
if (canEdit || keys.filter(function(key) { if (canEdit || keys.filter(function(key) {