PHP code example of joassanon / image-optimizer

1. Go to this page and download the library: Download joassanon/image-optimizer 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/ */

    

joassanon / image-optimizer example snippets


Vendor\\ImageOptimizer\\ImageOptimizerServiceProvider::class,
bash
php artisan vendor:publish --provider="Vendor\\ImageOptimizer\\ImageOptimizerServiceProvider" --tag=config
tsx
import { OptimizedImage } from '@joassanon/optimized-image';

export default function ProductImage() {
  return (
    <OptimizedImage
      src="images/products/shoe.jpg"
      alt="Running shoe"
      widths={[320, 640, 960, 1280]}
      sizes="(max-width: 768px) 100vw, 50vw"
      quality={80}
      format="webp"
      priority={false}
      placeholder="images/products/shoe-blur.jpg"
      className="responsive-image"
      style={{ borderRadius: '8px' }}
    />
  );
}