mirror of
https://github.com/philomena-dev/philomena.git
synced 2025-02-07 23:06:42 +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
|
def thumbnail_changeset(image, attrs) do
|
||||||
image
|
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)
|
|> change(thumbnails_generated: true, duplication_checked: true)
|
||||||
end
|
end
|
||||||
|
|
||||||
def process_changeset(image, attrs) do
|
def process_changeset(image, attrs) do
|
||||||
image
|
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)
|
|> change(processed: true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -134,7 +134,8 @@ defmodule Philomena.Images.Thumbnailer do
|
||||||
"image_sha512_hash" => Sha512.file(file),
|
"image_sha512_hash" => Sha512.file(file),
|
||||||
"image_size" => File.stat!(file).size,
|
"image_size" => File.stat!(file).size,
|
||||||
"image_width" => width,
|
"image_width" => width,
|
||||||
"image_height" => height
|
"image_height" => height,
|
||||||
|
"image_aspect_ratio" => width / height
|
||||||
})
|
})
|
||||||
|> Repo.update!()
|
|> Repo.update!()
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue