Skip to content

Commit a7902d4

Browse files
committed
update compatibility for WordPress 6.6 & fixed potential error on attachment pages
1 parent 9ca9460 commit a7902d4

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

classes/eml/Controller/class-external-files.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ public function get_file_by_url( string $url ): ?External_File {
709709
$result = new WP_Query( $query );
710710
if ( 1 === $result->post_count ) {
711711
$external_file_obj = $this->get_file( $result->posts[0] );
712-
if ( $external_file_obj->is_valid() ) {
712+
if ( $external_file_obj && $external_file_obj->is_valid() ) {
713713
return $external_file_obj;
714714
}
715715
}
@@ -742,7 +742,7 @@ public function get_file_by_title( string $title ): bool|External_File {
742742
$result = new WP_Query( $query );
743743
if ( 1 === $result->post_count ) {
744744
$external_file_obj = $this->get_file( $result->posts[0] );
745-
if ( $external_file_obj->is_valid() ) {
745+
if ( $external_file_obj && $external_file_obj->is_valid() ) {
746746
return $external_file_obj;
747747
}
748748
}

classes/eml/Controller/class-init.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,8 @@ public function image_downsize( array|bool $result, int $attachment_id ): bool|a
286286

287287
// check if the file is an external file, an image and if it is really external hosted.
288288
if (
289-
$external_file_obj->is_valid()
289+
$external_file_obj
290+
&& $external_file_obj->is_valid()
290291
&& false === $external_file_obj->is_locally_saved()
291292
&& $external_file_obj->is_image()
292293
) {
@@ -324,7 +325,8 @@ public function wp_calculate_image_srcset( array $sources, array $size_array, st
324325

325326
// check if the file is an external file, an image and if it is really external hosted.
326327
if (
327-
$external_file_obj->is_valid()
328+
$external_file_obj
329+
&& $external_file_obj->is_valid()
328330
&& false === $external_file_obj->is_locally_saved()
329331
&& $external_file_obj->is_image()
330332
) {
@@ -349,7 +351,8 @@ public function prevent_external_attachment_in_export( array $value, array $para
349351

350352
// check if the file is an external file, an image and if it is really external hosted.
351353
if (
352-
$external_file_obj->is_valid()
354+
$external_file_obj
355+
&& $external_file_obj->is_valid()
353356
&& false === $external_file_obj->is_locally_saved()
354357
&& $external_file_obj->is_image()
355358
) {
@@ -424,7 +427,7 @@ public function wp_get_attachment_metadata( array $data, int $attachment_id ): a
424427
$external_file_obj = $this->external_files_obj->get_file( $attachment_id );
425428

426429
// check if the file is an external file.
427-
if ( $external_file_obj->is_valid() ) {
430+
if ( $external_file_obj && $external_file_obj->is_valid() ) {
428431
$data['file'] = get_permalink( $attachment_id );
429432
}
430433
return $data;

readme.txt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
Contributors: threadi
33
Tags: external files, media library, media
44
Requires at least: 6.2
5-
Tested up to: 6.5.3
5+
Tested up to: 6.6
66
Requires PHP: 8.0
77
License: GPL-2.0-or-later
88
License URI: https://www.gnu.org/licenses/gpl-2.0.html
9-
Stable tag: 1.2.1
9+
Stable tag: 1.2.2
1010

1111
Add external files to your media library to link or embed them in your website. They will be integrated as if they were locally available.
1212

@@ -88,3 +88,8 @@ No, only public files can be used.
8888
* Added support for hook of plugin "Download List Block with Icons" for mark external files with rel-external
8989
* Updated compatibility-flag for WordPress 6.5.3
9090
* Updated dependencies
91+
92+
= 1.2.2 =
93+
* Updated compatibility-flag for WordPress 6.6
94+
* Updated dependencies
95+
* Fixed potential error on attachment pages

0 commit comments

Comments
 (0)