Last active
March 7, 2016 10:40
-
-
Save MjHead/cb45ca09a97b1b7f62d7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Constructor | |
*/ | |
public function __construct() { | |
/** | |
* Constructor body | |
*/ | |
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_assets' ), 9 ); | |
} | |
/** | |
* Check widget settings and maybe change image size to smaller | |
* | |
* @param string $size Default image size. | |
* @param array $instance Widget instance. | |
* @param array $args Current widget area arguments. | |
* @return string | |
*/ | |
public function set_image_size( $size, $instance, $args ) { | |
$areas_to_rewrite = array( | |
'after-content-full-width-area', | |
'full-width-header-area', | |
); | |
$rewrite_from = 5; | |
if ( ! isset( $args['id'] ) || ! in_array( $args['id'], $areas_to_rewrite ) ) { | |
return $size; | |
} | |
if ( ! isset( $instance['slides_per_view'] ) || $rewrite_from > intval( $instance['slides_per_view'] ) ) { | |
return $size; | |
} | |
return 'post-thumbnail'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment