PHP code example of infernalmedia / responsive-image-craft

1. Go to this page and download the library: Download infernalmedia/responsive-image-craft library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

infernalmedia / responsive-image-craft example snippets


return [
    'use_responsive_images' => env('USE_RESPONSIVE_IMAGES', true),
    'source_disk' => env('RESPONSIVE_IMAGES_SOURCE_DISK', 'public'),
    'target_disk' => env('RESPONSIVE_IMAGES_TARGET_DISK', 's3'),
    'source_directory' => env('RESPONSIVE_IMAGES_SOURCE_DIRECTORY', 'images'),
    'target_directory' => env('RESPONSIVE_IMAGES_TARGET_DIRECTORY', 'images'),
    'sizes' => explode(',', env('RESPONSIVE_IMAGES_SIZES', "320,640,880,1024,1200,1760,2100")),
    'extensions' => [
        "jpg",
        "png",
        "avif",
        "webp",
    ],
    'extensions_filters_rules' => [
        "jpg" => ["png"],
        "png" => ["jpg"],
        "webp" => [],
        "avif" => [],
    ],
    'extensions_to_ignore' => [
        'svg'
    ],
    'filename_to_ignore' => [
        'favicon'
    ],
    'supported_file_extensions' => [
        "jpg",
        "webp",
        "png",
        "avif",
        "gif",
        "tiff",
        "pjpg"
    ],
    'filename_spacer' => '@',
    'container_css_class_name' => 'img-container'
    'scss_path' => resource_path('/scss/utilities'),
];

<x-infernal-responsive-img src="full/path/to/generated/image.original-extension"
                            alt="the alternate text"
                            height=1570 {{-- original height --}}
                            width=1216 {{-- original width --}} />

<x-infernal-responsive-img src="full/path/to/generated/image.original-extension"
                            alt="the alternate text"
                            container-class="the-css-class-to-add-to-the-wrapping-container" {{-- optional --}}
                            height=1570 {{-- original height --}}
                            width=1216 {{-- original width --}}
                            :async-decoding="true" 
                            :lazy="true" 
                            :skip-picture-tag="false" 
                            img-attributes="attributes to add to img tag" />
bash
php artisan vendor:publish --tag="responsive-image-craft-config"
bash
php artisan vendor:publish --tag="responsive-image-craft-scss"
bash
php artisan responsive-image-craft:generate