Skip to content
Snippets Groups Projects
Unverified Commit 1a798914 authored by Arnaud Levy's avatar Arnaud Levy Committed by GitHub
Browse files

Précalcul du format de l'image (#1734)


* not tested

* check if ratio is present

---------

Co-authored-by: default avatarSébastien Gaya <sebastien.gaya@gmail.com>
parent d4e05bb8
No related branches found
No related tags found
No related merge requests found
<%
width, height = @about.metadata.values_at('width', 'height')
ratio = width.present? && height.present? ? (width.to_f / height.to_f) : nil
format = 'square'
if ratio.present?
format = 'landscape' if ratio > 1
format = 'portrait' if ratio < 1
end
university = University.find_by(id: @about.university_id)
base_url = university&.url || ""
media_endpoint_path = medium_path(signed_id: @about.signed_id, filename_with_transformations: @about.filename)
......@@ -12,6 +17,7 @@ media_endpoint_path = medium_path(signed_id: @about.signed_id, filename_with_tra
"width" => width,
"height" => height,
"ratio" => ratio,
"format" => format,
"url" => "#{base_url}#{media_endpoint_path}",
"direct_url" => @about.url
}.compact.to_yaml) %>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment