aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma/upload.ex
diff options
context:
space:
mode:
authorAlex Gleason <alex@alexgleason.me>2021-05-12 13:38:11 -0500
committerAlex Gleason <alex@alexgleason.me>2021-05-12 15:07:31 -0500
commitab9eabdf20180f2dd8539cf5d3dc0fdc6412496b (patch)
tree3d9c077184c9f9aba5c335e90157ecaf6d754773 /lib/pleroma/upload.ex
parentb221d77a6da07c684bdbc63ddf4500e0d7ffeae8 (diff)
downloadpleroma-ab9eabdf20180f2dd8539cf5d3dc0fdc6412496b.tar.gz
Add SetMeta filter to store uploaded image sizes
Diffstat (limited to 'lib/pleroma/upload.ex')
-rw-r--r--lib/pleroma/upload.ex9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/pleroma/upload.ex b/lib/pleroma/upload.ex
index 654711351..4d58abd48 100644
--- a/lib/pleroma/upload.ex
+++ b/lib/pleroma/upload.ex
@@ -23,6 +23,8 @@ defmodule Pleroma.Upload do
is once created permanent and changing it (especially in uploaders) is probably a bad idea!
* `:tempfile` - path to the temporary file. Prefer in-place changes on the file rather than changing the
path as the temporary file is also tracked by `Plug.Upload{}` and automatically deleted once the request is over.
+ * `:width` - width of the media in pixels
+ * `:height` - height of the media in pixels
Related behaviors:
@@ -32,6 +34,7 @@ defmodule Pleroma.Upload do
"""
alias Ecto.UUID
alias Pleroma.Config
+ alias Pleroma.Maps
require Logger
@type source ::
@@ -53,9 +56,11 @@ defmodule Pleroma.Upload do
name: String.t(),
tempfile: String.t(),
content_type: String.t(),
+ width: integer(),
+ height: integer(),
path: String.t()
}
- defstruct [:id, :name, :tempfile, :content_type, :path]
+ defstruct [:id, :name, :tempfile, :content_type, :width, :height, :path]
defp get_description(opts, upload) do
case {opts[:description], Pleroma.Config.get([Pleroma.Upload, :default_description])} do
@@ -89,6 +94,8 @@ defmodule Pleroma.Upload do
"mediaType" => upload.content_type,
"href" => url_from_spec(upload, opts.base_url, url_spec)
}
+ |> Maps.put_if_present("width", upload.width)
+ |> Maps.put_if_present("height", upload.height)
],
"name" => description
}}