Skip to content

Commit

Permalink
add compatibily on native image generation WP
Browse files Browse the repository at this point in the history
  • Loading branch information
asadowski10 committed Aug 3, 2020
1 parent e7b9d47 commit b04e462
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 14 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Changelog

## 3.0.14 - 31 July 2020
- Deactive "big image size threshold"
## 3.0.14 - 3 August 2020
- Deactive "big image size threshold"
- Add compatibily with native image generation ( without WP Thumb )

## 3.0.13 - 31 July 2020
- Load image size generation on plugins_loaded thanks to @Rahe for this pull request
Expand Down
4 changes: 2 additions & 2 deletions advanced-responsive-images.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/*
Plugin Name: Advanced Responsive Images
Version: 3.0.13
Version: 3.0.14
Plugin URI: https://github.com/asadowski10/advanced-responsive-images
Description: WordPress plugin to implement custom HTML markup for responsive images
Author: Alexandre Sadowski
Expand All @@ -19,7 +19,7 @@
}

// Plugin constants
define( 'ARI_VERSION', '3.0.13' );
define( 'ARI_VERSION', '3.0.14' );
define( 'ARI_MIN_PHP_VERSION', '5.4' );
define( 'ARI_VIEWS_FOLDER_NAME', 'ari' );

Expand Down
18 changes: 10 additions & 8 deletions classes/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,19 @@ protected function init() {
add_action( 'init', array( $this, 'init_translations' ) );
add_filter( 'post_thumbnail_html', array( $this, 'post_thumbnail_html' ), 10, 5 );

// Override the calculated image sizes
add_filter( 'wp_calculate_image_sizes', '__return_false', PHP_INT_MAX );
if ( function_exists( 'wpthumb' ) ) {
// Override the calculated image sizes
add_filter( 'wp_calculate_image_sizes', '__return_false', PHP_INT_MAX );

// Override the calculated image sources
add_filter( 'wp_calculate_image_srcset', '__return_false', PHP_INT_MAX );
// Override the calculated image sources
add_filter( 'wp_calculate_image_srcset', '__return_false', PHP_INT_MAX );

// Remove the reponsive stuff from the content
remove_filter( 'the_content', 'wp_make_content_images_responsive' );
// Remove the reponsive stuff from the content
remove_filter( 'the_content', 'wp_make_content_images_responsive' );

// Disable the "BIG image" threshold value
add_filter( 'big_image_size_threshold', '__return_false' );
// Disable the "BIG image" threshold value
add_filter( 'big_image_size_threshold', '__return_false' );
}

}

Expand Down
6 changes: 4 additions & 2 deletions classes/modes/picture-lazyload.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ public function render_image( $html = '' ) {
/**
* @var $img_size Image_Sizes
*/
$img = wp_get_attachment_image_src( $this->attachment_id, (array) $img_size->get_image_size( $location->size ) );
$imgsize = function_exists( 'wp_thumb' ) ? (array) $img_size->get_image_size( $location->size ) : $location->size;
$img = wp_get_attachment_image_src( $this->attachment_id, $imgsize );
if ( empty( $img ) ) {
continue;
}
Expand All @@ -111,7 +112,8 @@ public function render_image( $html = '' ) {

// Add default img url
if ( isset( $location_array->img_base ) && ! empty( $location_array->img_base ) ) {
$default_img = wp_get_attachment_image_src( $this->attachment_id, (array) $img_size->get_image_size( $img_size ), false );
$imgsizedefault = function_exists( 'wp_thumb' ) ? (array) $img_size->get_image_size( $location_array->img_base ) : $location_array->img_base;
$default_img = wp_get_attachment_image_src( $this->attachment_id, $imgsizedefault, false );
} else {
$default_img = wp_get_attachment_image_src( $this->attachment_id, 'thumbnail', false );
}
Expand Down

0 comments on commit b04e462

Please sign in to comment.