From 8feb81ba68b844473b9e5b4cb50bc8abf8816528 Mon Sep 17 00:00:00 2001 From: rebeccahum Date: Mon, 4 Dec 2017 17:37:18 -0700 Subject: [PATCH 1/3] allow for default behavior and then apply filter if it exists --- class-instant-articles-post.php | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/class-instant-articles-post.php b/class-instant-articles-post.php index 2c1e362d..f28f9549 100644 --- a/class-instant-articles-post.php +++ b/class-instant-articles-post.php @@ -503,28 +503,21 @@ public function get_cover_media() { $cover_media = Image::create(); - - // If someone else is handling this, let them. Otherwise fall back to us trying to use the featured image. - if ( has_filter( 'instant_articles_cover_media' ) ) { - /** - * Filter the cover media. - * - * @since 0.1 - * @param Image $cover_media The cover media object. - * @param int $post_id The current post ID. - */ - $cover_media = apply_filters( 'instant_articles_cover_media', $cover_media, $this->_post->ID ); - } else { - - $featured_image_data = $this->get_the_featured_image(); - if ( isset( $featured_image_data['src'] ) && strlen( $featured_image_data['src'] ) ) { - $cover_media = Image::create()->withURL($featured_image_data['src']); - if( isset( $featured_image_data['caption'] ) && strlen( $featured_image_data['caption'] )) { - $cover_media->withCaption(Caption::create()->withTitle($featured_image_data['caption'])); - } + $featured_image_data = $this->get_the_featured_image(); + if ( isset( $featured_image_data['src'] ) && strlen( $featured_image_data['src'] ) ) { + $cover_media = Image::create()->withURL($featured_image_data['src']); + if( isset( $featured_image_data['caption'] ) && strlen( $featured_image_data['caption'] )) { + $cover_media->withCaption(Caption::create()->withTitle($featured_image_data['caption'])); } } + /** + * Filter the cover media. + * + * @since 0.1 + * @param Image $cover_media The cover media object. + * @param int $post_id The current post ID. + $cover_media = apply_filters( 'instant_articles_cover_media', $cover_media, $this->_post->ID ); return $cover_media; } From e66a1089459582c6f6c8a690acd0a310e2d745d6 Mon Sep 17 00:00:00 2001 From: rebeccahum Date: Mon, 4 Dec 2017 17:37:29 -0700 Subject: [PATCH 2/3] spacing --- class-instant-articles-post.php | 1 + 1 file changed, 1 insertion(+) diff --git a/class-instant-articles-post.php b/class-instant-articles-post.php index f28f9549..65519774 100644 --- a/class-instant-articles-post.php +++ b/class-instant-articles-post.php @@ -517,6 +517,7 @@ public function get_cover_media() { * @since 0.1 * @param Image $cover_media The cover media object. * @param int $post_id The current post ID. + */ $cover_media = apply_filters( 'instant_articles_cover_media', $cover_media, $this->_post->ID ); return $cover_media; } From 247073bdf06ae3ad05f24466cf2414d4d06e7938 Mon Sep 17 00:00:00 2001 From: rebeccahum Date: Mon, 4 Dec 2017 17:41:07 -0700 Subject: [PATCH 3/3] Spacing again --- class-instant-articles-post.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/class-instant-articles-post.php b/class-instant-articles-post.php index 65519774..a179f499 100644 --- a/class-instant-articles-post.php +++ b/class-instant-articles-post.php @@ -512,12 +512,12 @@ public function get_cover_media() { } /** - * Filter the cover media. - * - * @since 0.1 - * @param Image $cover_media The cover media object. - * @param int $post_id The current post ID. - */ + * Filter the cover media + * + * @since 0.1 + * @param Image $cover_media The cover media object. + * @param int $post_id The current post ID. + */ $cover_media = apply_filters( 'instant_articles_cover_media', $cover_media, $this->_post->ID ); return $cover_media; }