• Resolved penjetti

    (@penjetti)


    Nelio Content changed my site’s WooCommerce image sizes. The images for the Shop Page (archive-product) were showing the full image. The images for the Product Detail page were also showing the full image. Now every single image is cropped to exactly the same height on both the Shop Page and the Product Detail page. All I did to change things was to disable Nelio External Featured Image and enable Nelio Content. I am really upset about this. I didn’t want Nelio Content – it has WAY too much when all I need is Nelio External Featured Image. But you discontinued Nelio External Featured Image. And now this. Please help.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author David Aguilera

    (@davilera)

    Hi Penjetti!

    First of all, thanks for getting in touch and letting us know that there might be something amiss. NelioEFI and Nelio Content follow a slightly different approach for inserting featured images.

    When you upload a regular image in your media library, this image will be automatically scaled and cropped to match the requirements defined by your theme. External featured images, on the other hand, can’t be scaled and cropped because they’re stored outside of WordPress.

    NelioEFI assumed that the dimensions of the image would be set using CSS rules solely. This worked fine with some themes, but had trouble with others. Nelio Content, on the other hand, uses a placeholder that your theme crops and scales and uses it to define the exact area that the featured image is supposed to take. This ensures that the dimensions of your image will match the requirements of your theme. As far as I can tell, Nelio Content offers better results than NelioEFI, and that’s why we decided to apply the shift.

    If you want to use the old approach for inserting featured images, add the following snippet in functions.php (or a custom plugin):

    
    function nc_use_old_efi_style( $html, $post_id, $size = false, $attr = array() ) {
    
      $aux = Nelio_Content_External_Featured_Image_Helper::instance();
      $nelio_featured_image = $aux->get_nelio_featured_image( $post_id );
      if ( ! is_string( $nelio_featured_image ) || ! strlen( $nelio_featured_image ) ) {
        return $html;
      }//end if
    
      // Fix the alt tag (if possible).
      $alt = $aux->get_external_featured_alt( $post_id );
      if ( isset( $attr['alt'] ) ) {
        $alt = $attr['alt'];
      }//end if
      if ( empty( $alt ) ) {
        $alt = '';
      }//end if
    
      preg_match( '/class="([^"]*)"/', $html, $matches );
      $classes = '';
      if ( count( $matches ) > 1 ) {
        $classes = $matches[1];
      }//end if
    
      return sprintf(
        '<img src="%s" alt="%s" class="%s" />',
        esc_url( $nelio_featured_image ),
        esc_attr( $alt ),
        esc_attr( $classes )
      );
    
    }//end maybe_add_efi_as_background()
    add_filter( 'post_thumbnail_html', 'nc_use_old_efi_style', 20, 4 );
    

    Let me know if this helped!

    Thread Starter penjetti

    (@penjetti)

    I tried it and it does seem to work. I will let you know if I have any problems with the code. Thank you.

    Plugin Author David Aguilera

    (@davilera)

    Great ??

    I just wanted to let you know I had the same problem as the OP and the fix worked for me also. Luckily I use a child theme that has a functions.php file but for anyone that does not and uses a parent theme only this change will get overwritten whenever their theme gets updated. It would be nice if you could add this code into the plugin in a future update.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Nelio Content Changed (Messed Up) WooCommerce Image Sizes’ is closed to new replies.