# HG changeset patch # User Marcin Kuzminski # Date 2020-05-14 07:40:20 # Node ID 54aab712e601c09872c9dc29f5c59596db449a55 # Parent 2ba995a18ee3d679c3f8212d76195eabd2431c9f files: fixed unicode problems on image preview, and make images center, no-stretch. diff --git a/rhodecode/lib/helpers.py b/rhodecode/lib/helpers.py --- a/rhodecode/lib/helpers.py +++ b/rhodecode/lib/helpers.py @@ -1617,18 +1617,19 @@ def render_binary(repo_name, file_obj): Choose how to render a binary file """ + # unicode filename = file_obj.name # images - for ext in ['*.png', '*.jpg', '*.ico', '*.gif']: + for ext in ['*.png', '*.jpeg', '*.jpg', '*.ico', '*.gif']: if fnmatch.fnmatch(filename, pat=ext): - alt = escape(filename) src = route_path( 'repo_file_raw', repo_name=repo_name, commit_id=file_obj.commit.raw_id, f_path=file_obj.path) + return literal( - '{}'.format(alt, src)) + 'rendered-image'.format(src)) def renderer_from_filename(filename, exclude=None): diff --git a/rhodecode/public/css/code-block.less b/rhodecode/public/css/code-block.less --- a/rhodecode/public/css/code-block.less +++ b/rhodecode/public/css/code-block.less @@ -500,7 +500,7 @@ div.codeblock { img.rendered-binary { height: auto; - width: 100%; + width: auto; } .markdown-block { diff --git a/rhodecode/templates/files/files_source.mako b/rhodecode/templates/files/files_source.mako --- a/rhodecode/templates/files/files_source.mako +++ b/rhodecode/templates/files/files_source.mako @@ -115,7 +115,9 @@ %if c.file.is_binary: <% rendered_binary = h.render_binary(c.repo_name, c.file)%> % if rendered_binary: +
${rendered_binary} +
% else:
${_('Binary file ({})').format(c.file.mimetype)}