diff options
author | Haelwenn <contact+git.pleroma.social@hacktivis.me> | 2022-07-03 21:14:25 +0000 |
---|---|---|
committer | Haelwenn <contact+git.pleroma.social@hacktivis.me> | 2022-07-03 21:14:25 +0000 |
commit | de37583c49bb43b67c009c36d42967dd9d117acb (patch) | |
tree | 2b94dbfbc7563d6cd8a7b52714b55e64ecbefd4c /lib/pleroma/upload.ex | |
parent | a15b45a5897817a5a5accfb8fd0fa5bcf8515e2b (diff) | |
parent | 56227ef7ba097c6be39a7e70b67c426a3016e0ab (diff) | |
download | pleroma-de37583c49bb43b67c009c36d42967dd9d117acb.tar.gz |
Merge branch 'image_description_from_exif_data' into 'develop'
Use EXIF data of image for image description
See merge request pleroma/pleroma!3535
Diffstat (limited to 'lib/pleroma/upload.ex')
-rw-r--r-- | lib/pleroma/upload.ex | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/lib/pleroma/upload.ex b/lib/pleroma/upload.ex index 242813dcd..db2909276 100644 --- a/lib/pleroma/upload.ex +++ b/lib/pleroma/upload.ex @@ -60,12 +60,23 @@ defmodule Pleroma.Upload do width: integer(), height: integer(), blurhash: String.t(), + description: String.t(), path: String.t() } - defstruct [:id, :name, :tempfile, :content_type, :width, :height, :blurhash, :path] - - defp get_description(opts, upload) do - case {opts[:description], Pleroma.Config.get([Pleroma.Upload, :default_description])} do + defstruct [ + :id, + :name, + :tempfile, + :content_type, + :width, + :height, + :blurhash, + :description, + :path + ] + + defp get_description(upload) do + case {upload.description, Pleroma.Config.get([Pleroma.Upload, :default_description])} do {description, _} when is_binary(description) -> description {_, :filename} -> upload.name {_, str} when is_binary(str) -> str @@ -81,7 +92,7 @@ defmodule Pleroma.Upload do with {:ok, upload} <- prepare_upload(upload, opts), upload = %__MODULE__{upload | path: upload.path || "#{upload.id}/#{upload.name}"}, {:ok, upload} <- Pleroma.Upload.Filter.filter(opts.filters, upload), - description = get_description(opts, upload), + description = get_description(upload), {_, true} <- {:description_limit, String.length(description) <= Pleroma.Config.get([:instance, :description_limit])}, @@ -152,7 +163,8 @@ defmodule Pleroma.Upload do id: UUID.generate(), name: file.filename, tempfile: file.path, - content_type: file.content_type + content_type: file.content_type, + description: opts.description }} end end @@ -172,7 +184,8 @@ defmodule Pleroma.Upload do id: UUID.generate(), name: hash <> "." <> ext, tempfile: tmp_path, - content_type: content_type + content_type: content_type, + description: opts.description }} end end |