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
"/static/js/getItemTitle.SITENAME.js".
*/
"itemTitleKeys": ["title", "director", "date"],
"itemTitleKeys": ["title", "director", "year"],
/*
"itemViews" is an ordered list of available item views. Implemented views
are "info", "documents", "player", "editor", "timeline", "clips", "map",

View File

@ -260,12 +260,7 @@ pandora.ui.infoView = function(data) {
clickLink: pandora.clickLink,
collapseToEnd: false,
editable: canEdit,
format: function(value) {
return value.replace(
/<img src=/g,
'<img style="max-width: 256px; max-height: 256px; margin: 0 16px 16px 0" src='
);
},
format: imageCSS,
maxHeight: Infinity,
placeholder: formatLight(Ox._('No Summary')),
tooltip: canEdit ? pandora.getEditTooltip() : '',
@ -326,12 +321,7 @@ pandora.ui.infoView = function(data) {
descriptions[key] = Ox.EditableContent({
clickLink: pandora.clickLink,
editable: canEdit,
format: function(value) {
return value.replace(
/<img src=/g,
'<img style="float: left; max-width: 256px; max-height: 256px; margin: 0 16px 16px 0" src='
);
},
format: imageCSS,
placeholder: formatLight(Ox._('No {0} Description', [Ox._(Ox.toTitleCase(key))])),
tooltip: canEdit ? pandora.getEditTooltip() : '',
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) {
var $element;
if (canEdit || keys.filter(function(key) {