Commit Graph

11 Commits

Author SHA1 Message Date
evazion
756362f89e Fix #4990: Allow admins to delete uploads.
Allow admins to delete media asset files.

This only deletes the image file itself, not the upload or media asset record. The upload will still
be in the user's upload list, but the image will be gone. The media asset page will still exist, but
it will only show the file's metadata, not the image itself. We don't delete the metadata so we have
a record of what the file's MD5 was and who uploaded it, to prevent the file from being uploaded
again and to take action against the user if necessary.
2022-11-29 19:10:08 -06:00
evazion
0317ced63a media assets: fix unsafe redirect error in /media_assets/:id/:variant
Fix error when redirecting to image hosted on separate domain.
2022-11-01 18:03:58 -05:00
evazion
ad998a8127 media assets: add image redirect routes.
Add URLs that redirect from a media asset to the image:

* https://danbooru.donmai.us/media_assets/6961761/original -> https://cdn.donmai.us/original/2c/4f/2c4ff193b0fc7106e59b2f6696a68a02.jpg
* https://danbooru.donmai.us/media_assets/6961761/sample   -> https://cdn.donmai.us/sample/2c/4f/sample-2c4ff193b0fc7106e59b2f6696a68a02.jpg
* https://danbooru.donmai.us/media_assets/6961761/720x720  -> https://cdn.donmai.us/180x180/2c/4f/2c4ff193b0fc7106e59b2f6696a68a02.webp
* https://danbooru.donmai.us/media_assets/6961761/360x360  -> https://cdn.donmai.us/180x180/2c/4f/2c4ff193b0fc7106e59b2f6696a68a02.jpg
* https://danbooru.donmai.us/media_assets/6961761/180x180  -> https://cdn.donmai.us/180x180/2c/4f/2c4ff193b0fc7106e59b2f6696a68a02.jpg

This is useful if you have a media asset ID and want to get to the image
without looking up the image URL in the API.

This endpoint is rate-limited to 5 requests per second. It's not meant
to be used for things like thumbnail galleries or bulk scraping images.
2022-11-01 01:47:18 -05:00
evazion
b41b67af6c media assets: add dynamically-generated thumbnails (owner-only).
Add ability to dynamically generate thumbnails with:

* https://danbooru.donmai.us/media_assets/6961761.jpg?width=180&height=180

This is currently restricted to the Owner-level user because it's slow.
2022-11-01 01:36:38 -05:00
evazion
0b8d042c06 uploads: allow changing thumbnail size on My Uploads / All Uploads pages.
* Add a "Size" menu to the My Uploads / All Uploads pages to allow
  changing the thumbnail size.
* Make the My Uploads / All Uploads pages use the same thumbnail size as
  the post index page.
* Change the "Gallery | Table" links on the My Uploads page to icons.
2022-02-16 16:39:28 -06:00
evazion
f890e8595e uploads: respect user's posts-per-page setting on My Uploads page. 2022-02-16 16:38:47 -06:00
evazion
53a3beee35 uploads: refactor "My Uploads" page for multi-file uploads.
* Make thumbnails on the "My Uploads" page show an icon with an image
  count when an upload contains multiple files.

* Make the "My Uploads" page show each upload, not each individual file.
  If an upload contains multiple files, they're shown grouped together
  under a single upload. This does mean that failed or duplicate uploads
  will show up on this page now. This is because this page shows each
  upload attempt, not each uniquely uploaded file.
2022-02-14 00:41:07 -06:00
evazion
0132c5f0a5 media assets: fix md5 leak in media assets.
Fix unprivileged users being able to see images and MD5 hashes of media
assets belonging to censored posts.
2022-01-30 23:23:55 -06:00
evazion
a7dc05ce63 Enable frozen string literals.
Make all string literals immutable by default.
2021-12-14 21:33:27 -06:00
evazion
c99d0523bb /media_assets: add basic index and show pages.
* Add a basic index page at https://danbooru.donmai.us/media_assets.
* Add a basic show page at https://danbooru.donmai.us/media_assets/1.
* Add ability to search /media_assets.json by metadata. Example:
** https://danbooru.donmai.us/media_assets.json?search[metadata][File:ColorComponents]=3
* Add a "»" link next to the filesize on posts linking to the metadata page.

Known issues:

* Sometimes the MD5 links on the /media_assets page return "That record
  was not found" errors. These are unfinished uploads that haven't been
  made into posts yet.
* No good way to search for custom metadata fields in the search form.
* Design is ugly.
2021-09-29 07:46:11 -05:00
evazion
b068c113a8 Add MediaAsset model.
A MediaAsset represents an image or video file uploaded to Danbooru. It
stores the metadata associated with the image or video. This is to work
on decoupling files from posts so that images can be uploaded separately
from posts.
2021-09-02 06:07:52 -05:00