Skip to content

Instantly share code, notes, and snippets.

View piperhaywood's full-sized avatar

Piper Haywood piperhaywood

View GitHub Profile
@piperhaywood
piperhaywood / apprch-wp-srcset.php
Last active November 28, 2021 23:24
WordPress function to create HTML5 image element with 'srcset' and 'sizes' attributes for JPEGs and PNGs. Paste in to functions.php for use elsewhere in theme.
/**
* WordPress function to create HTML5 image element with 'srcset' and 'sizes' attributes for JPEGs and PNGs.
* Paste in to functions.php for use elsewhere in theme. Images in 'srcset' are created from all WordPress registered image sizes.
* Mime types 'image/jpg', 'image/png', and 'image/gif' are returned appropriately.
*
* @author Piper Haywood <piper@approach.co.uk>
* @link http://piperhaywood.com
* @link https://gist.github.com/piperhaywood/96ac07ea5f4999512275
*
* @example https://gist.github.com/piperhaywood/686cc0c788bd9fc3fa6e
@piperhaywood
piperhaywood / example_apprch-wp-srcset.php
Last active August 29, 2015 14:10
Example of apprch-wp-srcset
<?php
/**
* Example of using apprch_wp_srcset() within WordPress loop. For function code to paste in to functions.php file, see URL below.
* @link https://gist.github.com/piperhaywood/96ac07ea5f4999512275
*
* In example, browsers without
* 'srcset' image attribute support are served 'large' image in 'src'.WordPress function to
* create HTML5 image element with 'srcset' and 'sizes' attributes for JPEGs and PNGs.
*

Keybase proof

I hereby claim:

  • I am piperhaywood on github.
  • I am piperhaywood (https://keybase.io/piperhaywood) on keybase.
  • I have a public key ASAxZ7Cd-Xx0tXuNahh6lcqFyBwF4Vddy2dByU6vDKhLYwo

To claim this, I am signing this object: