Google AMP's latest thumbnail creation is vastly improved!

I have been playing with the latest AmpProject’s image creation parameters and delighted with the results.

It is no longer necessary to create thumbnails because AMP original images can be shrunk to the containing folder and without having to specify any image dimensions!

I created about a hundred thumbnails both from the thumbnails and the original images and the rendering difference is negligible!

https://johns-jokes.com/downloads/sp-a/jb-amp-img/index.php

The work is in progress and I have to sort out how to align the thumbnails :frowning:
Script to obtain an array of thumbnails:

	$path = $_SERVER['DOCUMENT_ROOT'] .'/subs/thumb/*.*';	
	$imgs = glob($path);
	$imgs = array_slice($imgs, mt_rand(0,88), 101);

Functiont to display thumbnail:

//===========================================================
function thumbnail($img, $title='Yes we have no title')	
:string 
{
	$result = <<< ____TMP
		<div class="dib thb contain cll fll">
			$title
			<amp-img 
					class  = "contain"
			    layout = "fill"
				  src="$img"
  		  	alt="$title" 
			></amp-img>
		</div>
____TMP;

	return $result;	
}

HTML Script to display thumbnails:

<div class="tac">
  <?php 
    $path = '/var/www/ORIGINAL-IMAGES/';
	$len  = strlen( $path );
	foreach( $imgs as $id => $img):
  	  $title  = substr($img, $len);
	  $img    = 'https://www.johns-jokes.com/afiles/images/' 
		      .  $title;
	  echo thumbnail($img, $title);	
	endforeach;
  ?>	
</div>

Can you remember the good old days when thumbnails had to be created and the effort involved trying to render the images :slight_smile:

3 Likes

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.