mirror of
https://github.com/philomena-dev/philomena.git
synced 2025-02-01 03:46:44 +01:00
Update aspect ratio on dimension change
This commit is contained in:
parent
8e6e45d540
commit
b24a252cb8
2 changed files with 16 additions and 3 deletions
|
@ -235,13 +235,25 @@ defmodule Philomena.Images.Image do
|
|||
|
||||
def thumbnail_changeset(image, attrs) do
|
||||
image
|
||||
|> cast(attrs, [:image_sha512_hash, :image_size, :image_width, :image_height])
|
||||
|> cast(attrs, [
|
||||
:image_sha512_hash,
|
||||
:image_size,
|
||||
:image_width,
|
||||
:image_height,
|
||||
:image_aspect_ratio
|
||||
])
|
||||
|> change(thumbnails_generated: true, duplication_checked: true)
|
||||
end
|
||||
|
||||
def process_changeset(image, attrs) do
|
||||
image
|
||||
|> cast(attrs, [:image_sha512_hash, :image_size, :image_width, :image_height])
|
||||
|> cast(attrs, [
|
||||
:image_sha512_hash,
|
||||
:image_size,
|
||||
:image_width,
|
||||
:image_height,
|
||||
:image_aspect_ratio
|
||||
])
|
||||
|> change(processed: true)
|
||||
end
|
||||
|
||||
|
|
|
@ -134,7 +134,8 @@ defmodule Philomena.Images.Thumbnailer do
|
|||
"image_sha512_hash" => Sha512.file(file),
|
||||
"image_size" => File.stat!(file).size,
|
||||
"image_width" => width,
|
||||
"image_height" => height
|
||||
"image_height" => height,
|
||||
"image_aspect_ratio" => width / height
|
||||
})
|
||||
|> Repo.update!()
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue