📸Images & media
Last updated
Last updated
Welcome to the Image Processing and Storage section of our wiki! In this guide, we will explore how to efficiently handle image management within our application using Cloudinary.
Cloudinary is a powerful cloud-based service that provides an extensive suite of tools for image upload, storage, and manipulation. It allows developers to easily integrate image processing capabilities into their applications, making it simple to transform, resize, and optimize images on-the-fly. And the best part is it has a very generous free plan as the free credits renew monthly 🎉
By leveraging Cloudinary, we can enhance our application's performance and improve the user experience through faster image delivery and efficient management. Let's get started!
To get started with Cloudinary, you need to create an account on their website, find your API key, and add it to your .env file in your LightningRails application.
Active Storage enables the upload of files to cloud storage services, such as Cloudinary, and allows you to link these files to Active Record models.
This sets up two database tables to manage the relationships between files uploaded to Cloudinary and any model within our application.
Once Cloudinary is set up, you can easily attach images to your models using Active Storage or another file attachment library. This section will cover how to associate image uploads with your database models, ensuring that your images are properly linked and accessible.
Setup for one image
In your controller:
In your view:
Setup for multiple images
In your controller:
In your view:
To display the image on your view, we will need to change the image_tag by cl_image_tag and call its key:
Et voila! 🥖 You have a free cloud provider for your rails images.