diff --git a/CHANGES.md b/CHANGES.md index 5675827..64db486 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,7 +1,10 @@ # Changelog -## +## 1.8.2 (2/8/19) +* Fixed: Broken layout when using [col] shortcodes with image attribute. * Fixed: Hidden overflow on widgets hiding grid slider arrows. +* Fixed: Jetpack Photon "Speed up image load times" setting blowing up image srcset filters. +* Fixed: Error when switching to a non-Mai Theme in multisite. ## 1.8.1 (2/7/19) * Fixed: Hotfix for missing argument in srscet function. diff --git a/lib/classes/class-col.php b/lib/classes/class-col.php index dcddcaf..4a0d9a7 100644 --- a/lib/classes/class-col.php +++ b/lib/classes/class-col.php @@ -84,6 +84,11 @@ function render() { */ function get_col() { + // Trim because testing returned string of nbsp. + $this->content = mai_get_processed_content( trim( $this->content ) ); + + $image = $overlay = ''; + $attributes = array( 'class' => $this->get_classes(), 'id' => ! empty( $this->args['id'] ) ? $this->args['id'] : '', @@ -138,8 +143,12 @@ function get_col() { $image_id = absint( $this->args['image'] ); } - // Add the aspect ratio attributes. - $attributes = mai_add_background_image_attributes( $attributes, $image_id, $this->args['image_size'] ); + // Do the image. + $image_html = wp_get_attachment_image( $image_id, $this->args['image_size'], false, array( 'class' => 'bg-image' ) ); + if ( $image_html ) { + $attributes['class'] .= ' has-bg-image'; + $image = wp_image_add_srcset_and_sizes( $image_html, wp_get_attachment_metadata( $image_id ), $image_id ); + } } // If we have a valid overlay. @@ -150,8 +159,11 @@ function get_col() { $light_content = true; } + // Build the overlay. + $overlay = mai_get_overlay_html( $this->args['overlay'] ); + // Add overlay classes. - $attributes['class'] = mai_add_overlay_classes( $attributes['class'], $this->args['overlay'] ); + $attributes['class'] .= ' has-overlay'; } // Shade class @@ -170,14 +182,17 @@ function get_col() { // Maybe add inline styles. $attributes = mai_add_inline_styles( $attributes, $this->args['style'] ); - // Trim because testing returned string of nbsp. - $this->content = trim( $this->content ); - /** * Return the content with col wrap. * With flex-col attr so devs can filter elsewhere. */ - return sprintf( '
%s%s
', genesis_attr( 'flex-col', $attributes, $this->args ), mai_get_processed_content( $this->content ), $bg_link ); + return sprintf( '
%s%s%s%s
', + genesis_attr( 'flex-col', $attributes, $this->args ), + $image, + $overlay, + $this->content, + $bg_link + ); } /** diff --git a/lib/classes/class-section.php b/lib/classes/class-section.php index b584bda..27578b0 100644 --- a/lib/classes/class-section.php +++ b/lib/classes/class-section.php @@ -15,7 +15,6 @@ class Mai_Section { private $has_overlay; private $has_inner; - public function __construct( $args = array(), $content = null ) { // Save original args in a variable for filtering later. @@ -223,7 +222,11 @@ function get_section_open() { } // Build the opening markup. - return sprintf( '<%s %s>%s', $this->args['wrapper'], genesis_attr( $this->args['context'], $attributes, $this->args ), $inner_html ); + return sprintf( '<%s %s>%s', + $this->args['wrapper'], + genesis_attr( $this->args['context'], $attributes, $this->args ), + $inner_html + ); } /** @@ -495,6 +498,16 @@ function get_section_wrap_close() { */ function calculate_srcset( $sources, $size_array, $image_src, $image_meta, $attachment_id ) { + // Bail if no sources. + if ( ! is_array( $sources ) ) { + return $sources; + } + + // Bail if Jetpack Photon (image performance) is active. + if ( class_exists( 'Jetpack_Photon' ) && class_exists( 'Jetpack' ) && Jetpack::is_module_active( 'photon' ) ) { + return $sources; + } + $sizes = $image_meta['sizes']; // Bail if no sizes. @@ -502,28 +515,40 @@ function calculate_srcset( $sources, $size_array, $image_src, $image_meta, $atta return $sources; } - foreach( $sizes as $size => $values ) { + $theme_sizes = array( 'full-width', 'featured', 'one-half', 'one-third', 'one-fourth' ); + + foreach( $sizes as $size => $value ) { // Skip if not a size we want to check. - if ( ! in_array( $size, array( 'full-width', 'featured', 'one-half', 'one-third', 'one-fourth' ) ) ) { + if ( ! in_array( $size, $theme_sizes ) ) { continue; } // Get new image data. - $source = wp_get_attachment_image_src( $attachment_id, $size ); + $source = wp_get_attachment_image_src( $attachment_id, $size ); + if ( ! $source ) { + continue; + } + $url = $source[0]; $width = $source[1]; $height = $source[2]; + $crop = $source[3]; $ratio = $width/$height; $in_range = ( $ratio > 1 ) && ( $ratio < 3 ); + // Skip if not hard-cropping. + if ( ! $crop ) { + continue; + } + // Skip if this image size isn't a valid aspect ratio. if ( ! $in_range ) { continue; } // Add to our new srcset. - $sources[ $values['width'] ] = array( + $sources[ $value['width'] ] = array( 'url' => $url, 'descriptor' => 'w', 'value' => $width, diff --git a/mai-theme-engine.php b/mai-theme-engine.php index 73f2d36..c2a2348 100644 --- a/mai-theme-engine.php +++ b/mai-theme-engine.php @@ -5,7 +5,7 @@ * Plugin URI: https://maitheme.com/ * Description: The Mai Theme Engine plugin * - * Version: 1.8.1.1 + * Version: 1.8.2 * * GitHub URI: maithemewp/mai-theme-engine * @@ -89,7 +89,7 @@ public function __wakeup() { private function setup_constants() { // Plugin version. - define( 'MAI_THEME_ENGINE_VERSION', '1.8.1.1' ); + define( 'MAI_THEME_ENGINE_VERSION', '1.8.2' ); // DB version. define( 'MAI_THEME_ENGINE_DB_VERSION', '1400' ); @@ -146,7 +146,7 @@ private function hooks() { $updater = Puc_v4_Factory::buildUpdateChecker( 'https://github.com/maithemewp/mai-theme-engine/', __FILE__, 'mai-theme-engine' ); // Get the branch. If checking for beta releases. - $tester = genesis_get_option( 'mai_tester' ); + $tester = function_exists( 'genesis_get_option' ) && genesis_get_option( 'mai_tester' ); $tester = $tester ? 'beta' : 'master'; // Allow branch and updater object manipulation.