From d5e83dae866274811d791bf4a15723e8b92d895d Mon Sep 17 00:00:00 2001 From: Jacek Roszkowski Date: Mon, 11 Feb 2019 23:02:39 +0100 Subject: [PATCH] Add a check for post type --- external-media-without-import.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/external-media-without-import.php b/external-media-without-import.php index b41b1a2..8d24845 100644 --- a/external-media-without-import.php +++ b/external-media-without-import.php @@ -55,7 +55,9 @@ function init_emwi() { add_filter( 'get_attached_file', function( $file, $attachment_id ) { if ( empty( $file ) ) { $post = get_post( $attachment_id ); - return $post->guid; + if ( get_post_type( $post ) == 'attachment' ) { + return $post->guid; + } } return $file; }, 10, 2 );