diff --git a/functions-images.php b/functions-images.php index 0b96e33..15bd84c 100644 --- a/functions-images.php +++ b/functions-images.php @@ -54,18 +54,20 @@ function get_timber_image_src( $timber_image, $size ) { /** * Returns the srcset for a TimberImage. * - * @param int|Timber\Image $timber_image Instance of Timber\Image or attachment ID. - * @param string|array $size Size key or array of the image to return. + * @param int|Timber\Image $timber_image Instance of Timber\Image or attachment ID. + * @param string|array $size Size key or array of the image to return. + * @param array $args Optional args for the srcset. + * * @return string|bool Image src. False if image can’t be found or no srcset is available. */ -function get_timber_image_srcset( $timber_image, $size ) { +function get_timber_image_srcset( $timber_image, $size, $args = [] ) { $image = Timmy::get_image( $timber_image, $size ); if ( ! $image ) { return false; } - return $image->srcset(); + return $image->srcset( $args ); } /** diff --git a/lib/Image.php b/lib/Image.php index c1230af..78e993b 100644 --- a/lib/Image.php +++ b/lib/Image.php @@ -326,6 +326,13 @@ public function src_default() { return $src_default; } + /** + * Gets the srcset for an image. + * + * @param array $args Optional. Args for the srcset. + * + * @return false|string + */ public function srcset( $args = [] ) { $args = wp_parse_args( $args, [ 'webp' => $this->is_webp(),