Skip to content
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

Use Active Storage for Picture and File attachments #2968

Draft
wants to merge 28 commits into
base: main
Choose a base branch
from

Commits on Nov 27, 2024

  1. Add activestorage

    tvdeyen committed Nov 27, 2024
    Configuration menu
    Copy the full SHA
    a4f9e81 View commit details
    Browse the repository at this point in the history
  2. Add image_processing

    Necessary for active storage image transforms
    tvdeyen committed Nov 27, 2024
    Configuration menu
    Copy the full SHA
    fefae60 View commit details
    Browse the repository at this point in the history
  3. Add dragonfly to image processing converter

    ActiveStorage uses the image_processing gem to process images. This uses a hash to describe the conversion instead of a string
    tvdeyen committed Nov 27, 2024
    Configuration menu
    Copy the full SHA
    7486786 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    aaea3ef View commit details
    Browse the repository at this point in the history
  5. [ci] install libvips

    tvdeyen committed Nov 27, 2024
    Configuration menu
    Copy the full SHA
    effab20 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    dbe9155 View commit details
    Browse the repository at this point in the history
  7. Use custom validations for picture size and format

    Instead of using the Dragonfly Model validations we write our own. That way we can use another image attachment library more easily
    tvdeyen committed Nov 27, 2024
    Configuration menu
    Copy the full SHA
    da074b5 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    62082a7 View commit details
    Browse the repository at this point in the history
  9. Do not sharpen images by default

    The vips image_processing processor sharpens images by default. This disables this behavior.
    tvdeyen committed Nov 27, 2024
    Configuration menu
    Copy the full SHA
    6db7591 View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    cf418bb View commit details
    Browse the repository at this point in the history
  11. Delegate convertible format check to activestorage

    Active storage already knows if a file is convertible
    tvdeyen committed Nov 27, 2024
    Configuration menu
    Copy the full SHA
    4860766 View commit details
    Browse the repository at this point in the history
  12. Eager load attachments in admin pictures controller

    This avoids N+1 in the image library
    tvdeyen committed Nov 27, 2024
    Configuration menu
    Copy the full SHA
    ac8a7ea View commit details
    Browse the repository at this point in the history
  13. Delegate image_file_* methods to attached file

    Using activestorage methods to read the values.
    Ideally we would cache these values, but active
    storage asynchronously sets these values and provides
    no callback we could use.
    tvdeyen committed Nov 27, 2024
    Configuration menu
    Copy the full SHA
    9d3dd69 View commit details
    Browse the repository at this point in the history
  14. Remove custom picture variant classes

    Now that we use ActiveStorage we can remove our custom picture variant handling
    tvdeyen committed Nov 27, 2024
    Configuration menu
    Copy the full SHA
    ada5507 View commit details
    Browse the repository at this point in the history
  15. Move can_be_cropped_to? into picture_thumbnails

    This method is the only one left after the PictureVariant and PictureThumb removal.
    tvdeyen committed Nov 27, 2024
    Configuration menu
    Copy the full SHA
    16a7419 View commit details
    Browse the repository at this point in the history
  16. Configuration menu
    Copy the full SHA
    06e6ee1 View commit details
    Browse the repository at this point in the history
  17. Configuration menu
    Copy the full SHA
    a2fb41a View commit details
    Browse the repository at this point in the history
  18. Use file mime type for picture by format select

    Active storage has the mime type stored not the extension.
    tvdeyen committed Nov 27, 2024
    Configuration menu
    Copy the full SHA
    91446af View commit details
    Browse the repository at this point in the history
  19. Remove Dragonfly

    tvdeyen committed Nov 27, 2024
    Configuration menu
    Copy the full SHA
    d028c11 View commit details
    Browse the repository at this point in the history
  20. Add support for animated gifs

    ruby-vips and mini_magick need to be told to ignore
    the page in order to resize animated gifs.
    tvdeyen committed Nov 27, 2024
    Configuration menu
    Copy the full SHA
    652cea8 View commit details
    Browse the repository at this point in the history
  21. Always return image format

    Before we where not telling active storage that we want
    a certain format explicitely.
    We need that for displaying animated PNGs properly.
    tvdeyen committed Nov 27, 2024
    Configuration menu
    Copy the full SHA
    fd2835c View commit details
    Browse the repository at this point in the history
  22. Use ActiveStorage redirect path

    Proxy downloads the file.
    tvdeyen committed Nov 27, 2024
    Configuration menu
    Copy the full SHA
    950c289 View commit details
    Browse the repository at this point in the history
  23. Configuration menu
    Copy the full SHA
    dcb1bb7 View commit details
    Browse the repository at this point in the history
  24. Configuration menu
    Copy the full SHA
    642acb8 View commit details
    Browse the repository at this point in the history
  25. Preprocess thumbnails after upload

    Only works in Rails 7.1
    tvdeyen committed Nov 27, 2024
    Configuration menu
    Copy the full SHA
    d34db80 View commit details
    Browse the repository at this point in the history
  26. Use image_file_extension as original format

    ActiveStorage expects an extension and not an mime type.
    tvdeyen committed Nov 27, 2024
    Configuration menu
    Copy the full SHA
    6581373 View commit details
    Browse the repository at this point in the history
  27. Allow webp as image format for ActiveStorage

    It is only configured by default in unreleased Rails 7.2
    tvdeyen committed Nov 27, 2024
    Configuration menu
    Copy the full SHA
    3a44cef View commit details
    Browse the repository at this point in the history
  28. wip: append upgrader

    tvdeyen committed Nov 27, 2024
    Configuration menu
    Copy the full SHA
    9b2e8f7 View commit details
    Browse the repository at this point in the history