PHP code example of debjyotikar001 / media-lazy-load

1. Go to this page and download the library: Download debjyotikar001/media-lazy-load 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/ */

    

debjyotikar001 / media-lazy-load example snippets


protected $middleware = [
  // other middleware
  \Debjyotikar001\MediaLazyLoad\Middleware\MedLazyLoad::class,
];

protected $middleware = [
  // other middleware
  'medialazyload',
];

->withMiddleware(function (Middleware $middleware) {
  $middleware->web(append: [
    // other middleware
    \Debjyotikar001\MediaLazyLoad\Middleware\MedLazyLoad::class,
  ]);
})

->withMiddleware(function (Middleware $middleware) {
  $middleware->web(append: [
    // other middleware
    'medialazyload',
  ]);
})

// config/medialazyload.php
'enabled' => env('MEDLAZYLOAD_ENABLED', true),

'excluded_user_agents' => [
  'Googlebot',
  'Bingbot',
  'Slurp',
],

// config/medialazyload.php
'allowed_envs' => env('MEDLAZYLOAD_ALLOWED_ENVS', 'local,production,staging'),

'skip_urls' => [
    '/',
    'about',
    'user/*',
    '*_dashboard',
    '*/download/*',
  ],

// config/medialazyload.php
'rootMargin' => env('MEDLAZYLOAD_ROOTMARGIN', '0px 0px 100px 0px'),

// config/medialazyload.php
'threshold' => env('MEDLAZYLOAD_THRESHOLD', 0.1),
sh
php artisan vendor:publish --provider="Debjyotikar001\MediaLazyLoad\MediaLazyLoadServiceProvider"