Use resize_to_limit to avoid stretching images

This commit is contained in:
Christoph Haas 2020-08-17 01:48:51 +02:00
parent 53911f226d
commit b70a9f1a07
7 changed files with 13 additions and 13 deletions

View file

@ -1,7 +1,7 @@
json.package @p.name json.package @p.name
json.screenshots @p.screenshots do |s| json.screenshots @p.screenshots do |s|
json.small_image_url "https://#{request.host_with_port}#{s.image.variant(resize: "160x120", timestamp: false)}" json.small_image_url "https://#{request.host_with_port}#{s.image.variant(resize_to_limit: "160x120", timestamp: false)}"
json.large_image_url "https://#{request.host_with_port}#{s.image.variant(resize: "800x600", timestamp: false)}" json.large_image_url "https://#{request.host_with_port}#{s.image.variant(resize_to_limit: "800x600", timestamp: false)}"
json.version s.version json.version s.version
end end

View file

@ -4,7 +4,7 @@ json.cache! ['json_screenshots'], expires_in: 1.hour do
json.extract! s, :version json.extract! s, :version
json.extract! p, :maintainer, :name, :section, :maintainer_email, :homepage, :description json.extract! p, :maintainer, :name, :section, :maintainer_email, :homepage, :description
json.url package_url(p.name, protocol: 'https') json.url package_url(p.name, protocol: 'https')
json.small_image_url "https://#{request.host_with_port}#{s.image.variant(resize: "160x120")}" json.small_image_url "https://#{request.host_with_port}#{s.image.variant(resize_to_limit: "160x120")}"
json.large_image_url "https://#{request.host_with_port}#{s.image.variant(resize: "800x600")}" json.large_image_url "https://#{request.host_with_port}#{s.image.variant(resize_to_limit: "800x600")}"
end end
end end

View file

@ -16,8 +16,8 @@
- @current_users_screenshots.each do |screenshot| - @current_users_screenshots.each do |screenshot|
.column .column
a.black.fancybox href=rails_representation_url(screenshot.image.variant(resize: "800x600", timestamp: false)) a.black.fancybox href=rails_representation_url(screenshot.image.variant(resize_to_limit: "800x600", timestamp: false))
div.grid-thumbnail div.grid-thumbnail
= image_tag(screenshot.image.variant(resize: "160x120"), alt: screenshot.caption, class: 'thumbnail') = image_tag(screenshot.image.variant(resize_to_limit: "160x120"), alt: screenshot.caption, class: 'thumbnail')
div div
= screenshot.description = screenshot.description

View file

@ -4,7 +4,7 @@ a.black href=package_path(name: pkg.name)
- if pkg.screenshots_approved.any? - if pkg.screenshots_approved.any?
// TODO: smarter selection of the most useful screenshot instead of taking the first one // TODO: smarter selection of the most useful screenshot instead of taking the first one
- screenshot = pkg.screenshots.first - screenshot = pkg.screenshots.first
= image_tag(screenshot.image.variant(resize: "160x120"), alt: screenshot.caption, class: 'thumbnail') = image_tag(screenshot.image.variant(resize_to_limit: "160x120"), alt: screenshot.caption, class: 'thumbnail')
- else - else
img.screenshot.thumbnail src="/images/dummy/no-screenshots-upload-one.svg" img.screenshot.thumbnail src="/images/dummy/no-screenshots-upload-one.svg"
div div

View file

@ -20,8 +20,8 @@ h1 =@package.name
- screenshots_visible_to_user(@package).each do |screenshot| - screenshots_visible_to_user(@package).each do |screenshot|
.listview .listview
.text-center .text-center
a.black.fancybox href=rails_representation_url(screenshot.image.variant(resize: "800x600")) rel='fancybox-thumb' title=screenshot.caption a.black.fancybox href =rails_representation_url(screenshot.image.variant(resize_to_limit: [800,600])) rel='fancybox-thumb' title=screenshot.caption
= image_tag(screenshot.image.variant(resize: "800x600"), alt: screenshot.caption) = image_tag(screenshot.image.variant(resize_to_limit: [800,600]), alt: screenshot.caption)
- if screenshot.description - if screenshot.description
.imgcaption =screenshot.description .imgcaption =screenshot.description
- if screenshot.version.present? - if screenshot.version.present?

View file

@ -32,8 +32,8 @@ h1 = "Upload screenshots for #{@package.name}"
.small-up-1.medium-up-3.large-up-4.grid-thumbnails .small-up-1.medium-up-3.large-up-4.grid-thumbnails
- @package.screenshots.all.each do |ss| - @package.screenshots.all.each do |ss|
.column .column
a.black.fancybox href=rails_representation_url(ss.image.variant(resize: "800x600")) rel='fancybox-thumb' title=ss.caption a.black.fancybox href=rails_representation_url(ss.image.variant(resize_to_limit: "800x600")) rel='fancybox-thumb' title=ss.caption
= image_tag(ss.image.variant(resize: "160x120"), alt: ss.caption, class: 'thumbnail') = image_tag(ss.image.variant(resize_to_limit: "160x120"), alt: ss.caption, class: 'thumbnail')
// = render partial: 'packages/grid_thumbnail', locals: { pkg: pkg } // = render partial: 'packages/grid_thumbnail', locals: { pkg: pkg }
//- else //- else

View file

@ -30,7 +30,7 @@
h2 Newest upload h2 Newest upload
.thumb-height .thumb-height
a href=package_path(@newest_upload.package.name) a href=package_path(@newest_upload.package.name)
= image_tag(@newest_upload.image.variant(resize: "160x120"), alt: @newest_upload.caption) = image_tag(@newest_upload.image.variant(resize_to_limit: "160x120"), alt: @newest_upload.caption)
p p
strong strong
=@newest_upload.package.name =@newest_upload.package.name
@ -41,7 +41,7 @@
.thumb-height .thumb-height
- if @most_popular_package - if @most_popular_package
a href=package_path(@most_popular_package.name) a href=package_path(@most_popular_package.name)
= image_tag(@most_popular_package.screenshots.first.image.variant(resize: "160x120")) = image_tag(@most_popular_package.screenshots.first.image.variant(resize_to_limit: "160x120"))
- else - else
'No uploaded screenshots yet. 'No uploaded screenshots yet.
p p