Skip to content

Commit b64e455

Browse files
authored
release: fixes
- fatal error thrown because get_current_screen function is not loading in certain contexts - enhance image dimension handling when the width-height attributes are not provided.
2 parents c84e2bd + 63db960 commit b64e455

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

.distignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,7 @@ tailwind.config.js
4040
phpstan.neon
4141
development.php
4242
playwright.config.ts
43-
test-results
43+
test-results
44+
wp-scripts.config.js
45+
README.md
46+
CHANGELOG.md

inc/media_rename/attachment_edit.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ public function enqueue_scripts( $hook ) {
8585
* @return array Modified form fields.
8686
*/
8787
public function add_attachment_fields( $form_fields, $post ) {
88+
if ( ! function_exists( 'get_current_screen' ) ) {
89+
return $form_fields;
90+
}
91+
8892
$screen = get_current_screen();
8993

9094
$attachment = new Optml_Attachment_Model( $post->ID );

inc/tag_replacer.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,15 @@ public function filter_image_src_get_dimensions( $dimensions, $image_src, $image
8585
return $dimensions;
8686
}
8787
$sizes = Optml_App_Replacer::image_sizes();
88-
88+
if ( OPTML_DEBUG ) {
89+
do_action( 'optml_log', 'filter_image_src_get_dimensions: ' . $image_src . ' ' . $width . ' ' . $height . ' ' . print_r( $image_meta, true ) );
90+
}
91+
if ( $width === 'auto' && $height === 'auto' && isset( $image_meta['width'], $image_meta['height'] ) ) {
92+
return [
93+
$image_meta['width'],
94+
$image_meta['height'],
95+
];
96+
}
8997
// If this is an image size. Return its dimensions.
9098
foreach ( $sizes as $size => $args ) {
9199
if ( (int) $args['width'] !== (int) $width ) {

0 commit comments

Comments
 (0)