Skip to content

Commit 54a5d05

Browse files
committed
feat: Add FIFU (Featured Image from URL) plugin support
1 parent fb372b0 commit 54a5d05

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

includes/frontend/class-media-handler.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,23 @@ public static function get_the_post_thumbnail( $args = array() ) {
146146
}
147147
}
148148

149+
// If there is no thumbnail found, check FIFU (Featured Image from URL) plugin.
150+
if ( ! $postimage ) {
151+
/**
152+
* Filters the FIFU meta key used to store external image URLs.
153+
*
154+
* @param string $fifu_meta_key Meta key used by FIFU plugin.
155+
*/
156+
$fifu_meta_key = apply_filters( self::$prefix . '_fifu_meta_key', 'fifu_image_url' );
157+
158+
$fifu_image_url = get_post_meta( $result->ID, $fifu_meta_key, true );
159+
$fifu_image_url = filter_var( $fifu_image_url, FILTER_VALIDATE_URL );
160+
if ( $fifu_image_url ) {
161+
$postimage = $fifu_image_url;
162+
$pick = 'fifu';
163+
}
164+
}
165+
149166
// If there is no thumbnail found, check the post thumbnail.
150167
if ( ! $postimage ) {
151168
if ( false !== get_post_thumbnail_id( $result->ID ) ) {
@@ -264,7 +281,7 @@ public static function get_the_post_thumbnail( $args = array() ) {
264281

265282
$class = self::$prefix . "_{$pick} {$args['class']} {$args['size']}";
266283

267-
if ( empty( $attachment_id ) && ! in_array( $pick, array( 'video_thumb', 'default_thumb', 'site_icon_max', 'site_icon_min' ), true ) ) {
284+
if ( empty( $attachment_id ) && ! in_array( $pick, array( 'video_thumb', 'default_thumb', 'site_icon_max', 'site_icon_min', 'fifu' ), true ) ) {
268285
$attachment_id = self::get_cached_attachment_id( $postimage );
269286
}
270287

0 commit comments

Comments
 (0)