Skip to content

sreeram-softscripts/wp-tevko-responsive-images

 
 

Repository files navigation

RICG-responsive-images

Build Status

Bringing automatic default responsive images to WordPress.

This plugin works by including all available image sizes for each image upload. Whenever WordPress outputs the image through the media uploader, or whenever a featured image is generated, those sizes will be included in the image tag via the srcset attribute.

##Documentation

###For General Users

No configuration is needed! Just install the plugin and enjoy automatic responsive images!

###For Theme Developers

This plugin includes several functions that can be used by theme and plugin developers in templates.

####tevkori_get_sizes( $id, $size, $args )

Returns a valid source size value for use in a 'sizes' attribute. The parameters include the ID of the image, the default size of the image, and an array or string containing of size information. The ID parameter is required. Link

Usage Example

<img src="myimg.png" sizes="<?php echo tevkori_get_sizes( 11, 'medium' ); ?>" >

####tevkori_get_sizes_string( $id, $size, $args)

Returns an array of image source candidates for use in a 'srcset' attribute. The parameters include the ID of the image, the default size of the image, and An array of of srcset values. The ID parameter is required. Link

Usage Example

<img src="myimg.png" <?php echo tevkori_get_sizes_string( 11, 'medium' ); ?> >

####tevkori_get_srcset_string( $id, $size )

Returns A full 'srcset' attribute. The parameters include the ID of the image and its default size. The ID parameter is required. Link

Usage Example

<img src="myimg.png" <?php echo tevkori_get_srcset_string( 11, 'medium' ); ?> >

Dependencies

The only external dependency included in this plugin is Picturefill - v2.2.0-beta. If you would like to remove Picturefill, add the following line to your functions.php file: wp_dequeue_script('picturefill')

##Version

2.1.1

##Changelog

  • Adding in wp-tevko-responsive-images.js after file not found to be in wordpress repository
  • Adjusts the aspect ratio check in tevkori_get_srcset_array() to account for rounding variance

2.1.0

  • This version introduces a breaking change - there are now two functions. One returns an array of srcset values, and the other returns a string with the srcset=".." html needed to generate the responsive image. To retrieve the srcset array, use tevkori_get_srcset_array( $id, $size )

  • When the image size is changed in the post editor, the srcset values will adjust to match the change.

2.0.2

  • A bugfix correcting a divide by zero error. Some users may have seen this after upgrading to 2.0.1

2.0.1

  • Only outputs the default WordPress sizes, giving theme developers the option to extend as needed
  • Added support for featured images

2.0.0

  • Uses Picturefill 2.2.0 (Beta)
  • Scripts are output to footer
  • Image sizes adjusted
  • Most importantly, the srcset syntax is being used
  • The structure of the plugin is significantly different. The plugin now works by extending the default WordPress image tag functionality to include the srcset attribute.
  • Works for cropped images!
  • Backwards compatible (images added before plugin install will still be responsive)!

About

Fully responsive image plugin for wordpress

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 56.9%
  • PHP 37.7%
  • Shell 5.4%