uploadrest.blogg.se

Imageoptim gem
Imageoptim gem












imageoptim gem imageoptim gem
  1. #IMAGEOPTIM GEM UPDATE#
  2. #IMAGEOPTIM GEM CODE#
  3. #IMAGEOPTIM GEM DOWNLOAD#

At the moment I am using this approach only for when the user adds images to the content of a post or page, while I figure out a proper way of doing direct uploads to S3 for this with the text editor.ĪctiveStorage only requires that the attribute concerning an attachment be whitelisted in the params used to create or update a model object. This is the easiest way of handling uploads since it requires minimal JavaScript code. The way I do resizing and optimisation depends on whether the images are uploaded via the app itself, or directly to object storage. This process can have an even more significant impact on the file size than just reducing the resolution, depending on the image. To optimise the images by improving the compression with minimal to no loss in quality I use the  image_optim gem, which uses a number of tools behind the scenes to produce smaller images that still look good. To do this I use MiniMagick via the  ImageProcessing gem , which you will likely have in your Gemfile already if you use ActiveStorage.

#IMAGEOPTIM GEM CODE#

On the client I currently only limit the max file size to 5MB or even smaller for the blog logo, the favicon and the user avatar I also ensure that the selected files are images (there are things I check on the server as well).Īfter some quick research, I have determined that a good max width/height for images to be used for the web is 1200 pixels, so in my code I am resizing images according to this limit. There are ways to let the user resize images, at least, when they selected them and just before uploading them, but this depends on the client side library you use to handle uploads for now I am handling this server side. I cannot expect users to always prepare and optimise images prior to uploading, so I have added a little processing on upload to both resize and improve compression of the uploaded images for use with the web.

#IMAGEOPTIM GEM DOWNLOAD#

The problem I am facing with so many features requiring image uploads is that the user might upload images that are too large for their purpose or unoptimised in terms of compression and other qualities, resulting in worse performance for the end user (larger files take longer to download and render) as well as increased storage and bandwidth costs. DynaBlogger is a Rails app, so for this I use ActiveStorage, which is quickly becoming the standard way of handling uploads in Rails since it's built in the framework and doesn't require additional dependencies or even database migrations for models that require attachments, making things simpler than with other solutions provided that you stick to ActiveStorage's conventions. There are user uploads in the app for other things but the above are specifically for images.

imageoptim gem

logo/favicon/cover/twitter/facebook images for the blog.featured/cover/twitter/facebook images for posts and pages.My recently launched blogging platform DynaBlogger allows users to upload images in a number of places:














Imageoptim gem