From bd3fe673a65977c1bd8e3fbf70b1f744bc729ac1 Mon Sep 17 00:00:00 2001 From: Raju Mandapati Date: Mon, 10 Dec 2018 08:21:14 -0600 Subject: [PATCH 1/3] feat(filter): added filter to set tag type globally --- just-rwd-functions.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/just-rwd-functions.php b/just-rwd-functions.php index bd34760..0c7601b 100644 --- a/just-rwd-functions.php +++ b/just-rwd-functions.php @@ -21,7 +21,10 @@ * @param string $tag Specify which tag should be used: picture|img. * @param array $attr Additional html attributes to be used for main tag. */ -function rwd_attachment_image( $attachment = null, $size = 'thumbnail', $tag = 'picture', $attr = array() ) { +function rwd_attachment_image( $attachment = null, $size = 'thumbnail', $tag, $attr = array() ) { + if(empty($tag)) { + $tag = apply_filters( 'rwd_tag_type', 'picture' ); + } echo get_rwd_attachment_image( $attachment, $size, $tag, $attr ); } @@ -41,9 +44,8 @@ function rwd_attachment_image( $attachment = null, $size = 'thumbnail', $tag = ' * * @return string Generated html. */ -function get_rwd_attachment_image( $attachment = null, $size = 'thumbnail', $tag = 'picture', $attr = array() ) { +function get_rwd_attachment_image( $attachment = null, $size = 'thumbnail', $tag, $attr = array() ) { $rwd_image = new RwdImage( $attachment ); - $size = apply_filters( 'post_thumbnail_size', $size ); if ( 'img' != $tag ) { From d19db25c385d74d7f7b4857ebe0d13872fd4cc4a Mon Sep 17 00:00:00 2001 From: Raju Mandapati Date: Mon, 10 Dec 2018 08:49:14 -0600 Subject: [PATCH 2/3] fix(filters): added the filter to get_rwd_attachment_image as well --- just-rwd-functions.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/just-rwd-functions.php b/just-rwd-functions.php index 0c7601b..6a45f25 100644 --- a/just-rwd-functions.php +++ b/just-rwd-functions.php @@ -22,7 +22,7 @@ * @param array $attr Additional html attributes to be used for main tag. */ function rwd_attachment_image( $attachment = null, $size = 'thumbnail', $tag, $attr = array() ) { - if(empty($tag)) { + if( empty( $tag ) ) { $tag = apply_filters( 'rwd_tag_type', 'picture' ); } echo get_rwd_attachment_image( $attachment, $size, $tag, $attr ); @@ -46,6 +46,11 @@ function rwd_attachment_image( $attachment = null, $size = 'thumbnail', $tag, $a */ function get_rwd_attachment_image( $attachment = null, $size = 'thumbnail', $tag, $attr = array() ) { $rwd_image = new RwdImage( $attachment ); + + if( empty( $tag ) ) { + $tag = apply_filters( 'rwd_tag_type', 'picture' ); + } + $size = apply_filters( 'post_thumbnail_size', $size ); if ( 'img' != $tag ) { From a73ac72f74beac3156d6134b1b04fb0e62d9fe3e Mon Sep 17 00:00:00 2001 From: Raju Mandapati Date: Mon, 10 Dec 2018 08:54:57 -0600 Subject: [PATCH 3/3] fix(filter): setting $tag as optional argument --- just-rwd-functions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/just-rwd-functions.php b/just-rwd-functions.php index 6a45f25..2549b9f 100644 --- a/just-rwd-functions.php +++ b/just-rwd-functions.php @@ -21,7 +21,7 @@ * @param string $tag Specify which tag should be used: picture|img. * @param array $attr Additional html attributes to be used for main tag. */ -function rwd_attachment_image( $attachment = null, $size = 'thumbnail', $tag, $attr = array() ) { +function rwd_attachment_image( $attachment = null, $size = 'thumbnail', $tag = null, $attr = array() ) { if( empty( $tag ) ) { $tag = apply_filters( 'rwd_tag_type', 'picture' ); } @@ -44,7 +44,7 @@ function rwd_attachment_image( $attachment = null, $size = 'thumbnail', $tag, $a * * @return string Generated html. */ -function get_rwd_attachment_image( $attachment = null, $size = 'thumbnail', $tag, $attr = array() ) { +function get_rwd_attachment_image( $attachment = null, $size = 'thumbnail', $tag = null, $attr = array() ) { $rwd_image = new RwdImage( $attachment ); if( empty( $tag ) ) {