There is no license information available for the latest version (1.2.8) of this package.

A PHP wrapper for responsive HTML5 picture elements

1.2.8 2014-08-28 09:22 UTC


#Responsive Picture Elements

Build Status Scrutinizer Code Quality Coverage Status

A PHP wrapper for HTML5 picture element. See:


This library has no dependencies except from satooshi/php-coveralls for testing. Install from command line or composer.json file:

#####Command line

composer require tomkyle/responsivepicture

#####composer.json "require": { "tomkyle/responsivepicture": "~1.2" }

##Getting started

use \tomkyle\ResponsivePicture\MinWidthSource;
use \tomkyle\ResponsivePicture\ResponsivePicture;
use \tomkyle\ResponsivePicture\ResponsivePictureView;

$pic = new ResponsivePicture( '//', "Sample image");

$pic->add( new MinWidthSource(1200, '//, // 2x'));
$pic->add( new MinWidthSource(800,  '//,   // 2x'));
$pic->add( new MinWidthSource(480,  '//,   //   2x'));

##Create output Just create a ResponsivePictureView instance and echo it, optionally passing your ResponsivePicture object. You may start with no parameters and later set the ResponsivePicture, either by setter method or invoking:

// One-line call
echo new ResponsivePictureView( $pic );

// Use setter method
$foo = new ResponsivePictureView;
$foo->setPicture( $pic_view );
echo $foo;

// Or use with __invoke:
$bar = new ResponsivePictureView;
echo $bar( $pic1 );
echo $bar( $pic2 );    
echo $bar( $pic3 );    

##Testing Go to package root, install dependencies with composer update or install, run phpunit.