https://github.com/tomkyle/responsivepicture
A PHP wrapper for responsive HTML5 picture element
https://github.com/tomkyle/responsivepicture
Last synced: 7 months ago
JSON representation
A PHP wrapper for responsive HTML5 picture element
- Host: GitHub
- URL: https://github.com/tomkyle/responsivepicture
- Owner: tomkyle
- License: other
- Created: 2014-08-22T05:59:58.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2014-08-30T06:35:33.000Z (almost 12 years ago)
- Last Synced: 2024-12-29T11:45:36.260Z (over 1 year ago)
- Language: PHP
- Size: 352 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
#Responsive Picture Elements
[](https://travis-ci.org/tomkyle/ResponsivePicture)
[](https://scrutinizer-ci.com/g/tomkyle/ResponsivePicture/?branch=master)
[](https://coveralls.io/r/tomkyle/ResponsivePicture?branch=master)
A PHP wrapper for HTML5 picture element. See:
- Scott Jehl's [Picturefill – A responsive image polyfill](http://scottjehl.github.io/picturefill/)
- [Picturefill on Github](https://github.com/scottjehl/picturefill)
##Installation
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
add( new MinWidthSource(1200, '//placehold.it/1200x1200, //placehold.it/2400x2400 2x'));
$pic->add( new MinWidthSource(800, '//placehold.it/800x800, //placehold.it/1600x1600 2x'));
$pic->add( new MinWidthSource(480, '//placehold.it/480x480, //placehold.it/960x960 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:
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`.