Digittrix logo

Home - Scripts - Website Development

  • 14 January 2026

Cloudinary Media Upload & Fetch Images in Laravel

by Sunil M. 3 minute read 7 views

Modern web applications rely heavily on images and media assets. Whether you’re building a SaaS platform, an eCommerce store, or a business website, efficient media handling is essential. When companies hire Laravel developers for scalable projects, Cloudinary is often the preferred choice for media storage and optimization.

This guide explains how to integrate Cloudinary with Laravel using PHP 8+ and Laravel 8+. You’ll learn how to upload images, fetch and display them, apply transformations, and delete assets, all in line with best practices for custom web development and professional website development services.

Tech Stack Requirements

  • PHP: 8 or later
  • Laravel: 8 or later
  • Cloudinary Account: Required for API credentials

This setup is commonly used by teams offering enterprise-grade website development services and cloud-based Laravel solutions.

Why Use Cloudinary in Laravel Applications?

When businesses invest in custom web development, they expect performance, scalability, and security. Cloudinary helps Laravel applications meet these expectations offering:

  • Cloud-based image and media storage
  • Fast CDN-powered content delivery
  • Secure HTTPS URLs
  • Real-time image optimization
  • Dynamic transformations without server load

That’s why many agencies recommend Cloudinary when clients hire Laravel developers for media-heavy platforms.

Step 1: Installation and Configuration

Install the Cloudinary Laravel Package

Use Composer to install the official Laravel Cloudinary package:

                                        composer require unisharp/laravel-cloudinary
                                    

Publish the Configuration File

                                        php artisan vendor:publish --provider="Unisharp\\Cloudinary\\CloudinaryServiceProvider"
                                    

Configure Cloudinary Credentials

Obtain credentials from your Cloudinary dashboard and add them to the .env file:

                                        CLOUDINARY_CLOUD_NAME=your_cloud_name
CLOUDINARY_API_KEY=your_api_key
CLOUDINARY_API_SECRET=your_api_secret
                                    

This configuration is standard practice in secure website development services and in production-grade Laravel applications.

Step 2: Uploading Images to Cloudinary

Cloudinary provides an easy-to-use facade that uploads files directly from Laravel to the cloud. This keeps your application lightweight, an important factor in custom web development projects.

Example Controller Code (Upload Method)

                                        use Illuminate\Http\Request;
use Cloudinary;


public function uploadImage(Request $request)
{
    // 1. Validate the request
    $request->validate([
        'image' => 'required|image|mimes:jpeg,png,jpg,gif|max:2048', // Max 2MB
    ]);


    // 2. Upload the file to Cloudinary
    if ($request->hasFile('image')) {
        $uploadedFileUrl = Cloudinary::upload($request->file('image')->getRealPath(), [
            'folder' => 'laravel_images', // Optional: specify a folder
        ])->getSecurePath();


        // 3. Save the secure URL and public_id to your database
        $imageRecord = YourModel::create([
            'url' => $uploadedFileUrl,
            'public_id' => Cloudinary::getResult()['public_id'], // Save the public_id for future deletion/updates
        ]);


        return back()->with('success', 'Image uploaded successfully.');
    }


    return back()->with('error', 'Image upload failed.');
}
                                    

Why save public_id?

When clients hire Laravel developers, they often require future updates or deletions. Storing the public_id makes media management flexible and efficient.

Step 3: Fetching and Displaying Images

Once the secure URL is stored in the database, displaying images is straightforward.

Example Blade Template Code

                                        @foreach ($images as $image)
    <img src="{{ $image->url }}" alt="Uploaded Image" style="width: 300px; height: auto;">
@endforeach
                                    

This approach ensures optimized image delivery—an important feature in professional website development services.

Step 4: Image Transformations Using Cloudinary

Cloudinary enables real-time transformations directly via the image URL. This eliminates the need for server-side image processing, improving application performance.

Example: Resize Image Using URL Transformation

                                        @php
    // Example: Insert transformation string 'c_scale,w_400/' before '/v...' in the URL
    $transformedUrl = str_replace('/upload/', '/upload/c_scale,w_400/', $image->url);
@endphp
<img src="{{ $transformedUrl }}" alt="Resized Image">
                                    

Common Transformation Benefits

  • Faster page load times
  • Responsive image delivery
  • Automatic image optimization
  • Reduced server costs

These benefits are critical when building scalable platforms through custom web development.

Step 5: Deleting Images from Cloudinary

A clean delete process ensures no unused media remains in cloud storage.

Example Controller Code (Delete Method)

                                        public function deleteImage($id)
{
    $imageRecord = YourModel::findOrFail($id);


    // 1. Delete from Cloudinary using the public_id
    Cloudinary::destroy($imageRecord->public_id);


    // 2. Delete the record from your database
    $imageRecord->delete();


    return back()->with('success', 'Image deleted successfully.');
}
                                    

This structured approach is typically used by teams offering high-quality website development services.

When to Hire Laravel Developers for Cloud-Based Media Solutions

You should hire Laravel developers if your project requires:

  • Scalable cloud media storage
  • Secure image delivery
  • Performance-optimized applications
  • Custom admin panels for media management
  • Enterprise-level custom web development

Laravel, combined with Cloudinary, provides a future-ready solution for modern businesses.

Final Words

Integrating Cloudinary with Laravel is a powerful way to manage images efficiently while keeping your application fast and secure. From uploads and transformations to deletion and optimization, this setup follows industry standards for custom web development.

If your project involves heavy media usage, partnering with professionals or hiring Laravel developers experienced with Cloudinary integration can significantly improve performance, scalability, and user experience.

Tech Stack & Version

Frontend

  • HTML5
  • CSS3
  • Bootstrap
  • Tailwind CSS

Backend

  • PHP 8+
  • Laravel 8+ Framework
  • Cloudinary API
  • MySQL
  • PostgreSQL

Deployment

  • Linux Server
  • Apache
  • Nginx
  • AWS
  • DigitalOcean
img

©2026Digittrix Infotech Private Limited , All rights reserved.