-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Return media attachment dimensions #1985
Comments
Did some brief research into this, Paperclip has a companion gem for storing the asset dimensions in a database column: https://github.com/teeparham/paperclip-meta Beyond a basic db migration, it looks like it would require "rebuilding thumbnails", and I'm not sure what's involved in that. |
The dimension field can be optional, then we don't need to worry about rebuilding thumbnails -- a rebuild task can be added later if someone really want all media have dimensions. |
Tried for a while to get this, but it's beyond my abilities at the moment. If someone else could take a look, that'd be 💯 |
I'm looking into it! |
- add migration AddMediaAttachmentMeta, which add meta field to media_attachments - before saving attachment, set file meta if needed - add meta in api
Tried to add paperclip-meta, but it conflicts with paperclip-av-transcoder. I don't really want to monkey patch it, so I write some custom code to do that instead.
Note: file_meta is json type, which require newer postgresql (9.4) Result is something like: [
{
"media_attachments" : [
{
"id" : 4,
"type" : "image",
"remote_url" : "",
"meta" : {
"original" : {
"width" : 600,
"size" : "600x400",
"height" : 400,
"aspect" : 1.5
},
"small" : {
"aspect" : 1.49812734082397,
"height" : 267,
"size" : "400x267",
"width" : 400
}
},
"url" : "http://127.0.0.1:3000/system/media_attachments/files/000/000/004/original/3416fc5188c656da.jpg?1493138517",
"preview_url" : "http://127.0.0.1:3000/system/media_attachments/files/000/000/004/small/3416fc5188c656da.jpg?1493138517",
"text_url" : "http://127.0.0.1:3000/media/4hfW3Kt4U9UxDvV_xug"
},
{
"text_url" : "http://127.0.0.1:3000/media/0vTH_B1kjvIvlUBhGBw",
"preview_url" : "http://127.0.0.1:3000/system/media_attachments/files/000/000/003/small/23519a5e64064e32.png?1493138030",
"meta" : {
"fps" : 15,
"duration" : 5.06,
"width" : 320,
"size" : "320x180",
"height" : 180,
"length" : "0:00:05.06",
"aspect" : 1.77777777777778
},
"url" : "http://127.0.0.1:3000/system/media_attachments/files/000/000/003/original/23519a5e64064e32.mp4?1493138030",
"remote_url" : "",
"type" : "gifv",
"id" : 3
}
],
}
] |
Nice work @siuying ! |
* Fixes mastodon#1985 - add migration AddMediaAttachmentMeta, which add meta field to media_attachments - before saving attachment, set file meta if needed - add meta in api * add spec * align the “size” format for image and video * fix code climate * fixes media_attachment_spec.rb
* Fixes mastodon#1985 - add migration AddMediaAttachmentMeta, which add meta field to media_attachments - before saving attachment, set file meta if needed - add meta in api * add spec * align the “size” format for image and video * fix code climate * fixes media_attachment_spec.rb
* Wraps status timestamps in a `div` Fixes mastodon#1985 This wraps the status timestamp in a `div` to reduce the clickable target size of the link. The `div` gets a `margin: 0 0 0 auto` to stick it to the right margin of the status. * Update app/javascript/flavours/glitch/styles/components/status.scss Co-authored-by: Claire <claire.github-309c@sitedethib.com> Co-authored-by: Claire <claire.github-309c@sitedethib.com>
MediaAttachment currently do not return dimension of the image/video. This prevent the view from properly sized the placeholder.
If the api optionally return media dimension, we can make the client render the preview at proper size:
The text was updated successfully, but these errors were encountered: