medium', 'medium_large', 'large' ), true ) ) { $size_width = get_option( "{$size}_size_w" ); $size_height = get_option( "{$size}_size_h" ); } elseif ( isset( $_wp_additional_image_sizes[ $size ] ) ) { $size_width = $_wp_additional_image_sizes[ $size ]['width']; $size_height = $_wp_additional_image_sizes[ $size ]['height']; } // Skip if no width and height. if ( ! isset( $size_width, $size_height ) ) { continue; } // If within te limit, check for a max value. if ( $size_width <= $limit ) { $width = max( $width, $size_width ); } if ( $size_height <= $limit ) { $height = max( $height, $size_height ); } } return array( 'width' => $width, 'height' => $height, ); } /** * Update the image smushed count in transient * * @param string $key Database key. */ public static function update_smush_count( $key = 'bulk_sent_count' ) { $transient_name = WP_SMUSH_PREFIX . $key; $bulk_sent_count = get_transient( $transient_name ); // If bulk sent count is not set. if ( false === $bulk_sent_count ) { // Start transient at 0. set_transient( $transient_name, 1, 200 ); } elseif ( $bulk_sent_count < self::$max_free_bulk ) { // If lte $this->max_free_bulk images are sent, increment. set_transient( $transient_name, $bulk_sent_count + 1, 200 ); } } /** * Set the big image threshold. * * @since 3.3.2 * * @param int $threshold The threshold value in pixels. Default 2560. * @param array $imagesize Indexed array of the image width and height (in that order). * @param string $file Full path to the uploaded image file. * @param int $attachment_id Attachment post ID. * * @return int New threshold. */ public function big_image_size_threshold( $threshold, $imagesize, $file, $attachment_id ) { if ( ! Settings::get_instance()->get( 'resize' ) ) { return $threshold; } $resize_sizes = Settings::get_instance()->get_setting( WP_SMUSH_PREFIX . 'resize_sizes' ); if ( ! $resize_sizes || ! is_array( $resize_sizes ) ) { return $threshold; } return $resize_sizes['width'] > $resize_sizes['height'] ? $resize_sizes['width'] : $resize_sizes['height']; } }