Skip to content

Commit

Permalink
release: v3.9.1
Browse files Browse the repository at this point in the history
### Bug Fixes
- **Fatal error on PHP<7.3**: Fixed fatal error that the plugin was throwing on PHP versions lower than 7.3.
- **PHP Warning**: Fixed warning when inserting an image with a defined height but no width.
  • Loading branch information
abaicus authored Aug 7, 2023
2 parents 4da415c + ca02dd2 commit 6681850
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 5 deletions.
2 changes: 0 additions & 2 deletions assets/src/dashboard/utils/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ const highlightSidebarLink = () => {
};

const toggleDashboardSidebarSubmenu = ( show = true ) => {
console.log( '%c toggleDashboardSidebarSubmenu', 'color: #fff; background: #f00; font-size: 16px; padding: 4px 8px; border-radius: 4px;' );

const topLevel = document.querySelector( 'li#toplevel_page_optimole' );
let existingList = document.querySelector( 'li#toplevel_page_optimole .wp-submenu' );

Expand Down
2 changes: 1 addition & 1 deletion inc/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,7 @@ public function add_settings_subpage() {
__( 'Settings', 'optimole-wp' ),
'manage_options',
'optimole#settings',
[ $this, 'render_dashboard_page' ],
[ $this, 'render_dashboard_page' ]
);
}

Expand Down
2 changes: 1 addition & 1 deletion inc/dam.php
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ public function add_menu() {
__( 'Cloud Library', 'optimole-wp' ),
'manage_options',
'optimole-dam',
[ $this, 'render_dashboard_page' ],
[ $this, 'render_dashboard_page' ]
);
}

Expand Down
2 changes: 1 addition & 1 deletion inc/tag_replacer.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ private function parse_dimensions_from_tag( $tag, $image_sizes, $args = [] ) {
}
}
if ( preg_match( '#height=["|\']?([\d%]+)["|\']?#i', $tag, $height_string ) ) {
if ( ctype_digit( $width_string[1] ) === true ) {
if ( ctype_digit( $height_string[1] ) === true ) {
$args['height'] = $height_string[1];
}
}
Expand Down
23 changes: 23 additions & 0 deletions tests/test-replacer.php
Original file line number Diff line number Diff line change
Expand Up @@ -775,4 +775,27 @@ public function test_strip_metadata() {
$this->assertEquals( 27, substr_count( $replaced_content, '/sm:0/' ) );
}

public function test_tag_replacer_process_image_tags_missing_width_height() {
$test_data = [
[
'content' => '<div><img src="http://example.org/wp-content/uploads/2019/09/Screenshot.png" alt="" height="40"/></div>',
'expected' => '/w:auto/h:40/',
],
[
'content' => '<div><img src="http://example.org/wp-content/uploads/2019/09/Screenshot.png" alt="" width="50"/></div>',
'expected' => '/w:50/h:auto/',
],
[
'content' => '<div><img src="http://example.org/wp-content/uploads/2019/09/Screenshot.png" alt="" height="60" width="70"/></div>',
'expected' => '/w:70/h:60/',
]
];

foreach ( $test_data as $data ) {
$images = Optml_Manager::parse_images_from_html( $data['content'] );
$replaced_content = Optml_Tag_Replacer::instance()->process_image_tags( $data['content'], $images );

$this->assertStringContainsString( $data['expected'], $replaced_content );
}
}
}

0 comments on commit 6681850

Please sign in to comment.