From 78fcf3ca326bf53f7c402c7cc32fbba56ba5dc5d Mon Sep 17 00:00:00 2001 From: vnmedeiros Date: Tue, 26 Nov 2019 13:52:15 -0300 Subject: [PATCH] fix `insert_attachment_from_blob` get content of file on generete thumb --- src/classes/class-tainacan-media.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/classes/class-tainacan-media.php b/src/classes/class-tainacan-media.php index 108134bf4..f5ce558fc 100644 --- a/src/classes/class-tainacan-media.php +++ b/src/classes/class-tainacan-media.php @@ -52,7 +52,7 @@ class Media { return false; } - $file = fopen($filename,'r'); + $file = file_get_contents($filename); if (false === $file) { return false; @@ -75,7 +75,7 @@ class Media { return false; } - return $this->insert_attachment_from_blob(fopen($filename,'r'), basename($filename), $post_id); + return $this->insert_attachment_from_blob(file_get_contents($filename), basename($filename), $post_id); } @@ -142,7 +142,7 @@ class Media { do_action('tainacan-pre-insert-attachment', $blob, $filename, $post_id); - $upload = wp_upload_bits( $filename, null, '' ); + $upload = wp_upload_bits( $filename, null, $blob ); if( !empty( $upload['error'] ) ) { return false; }