Woocommerce single product gallery images cropped - wordpress

I'm using woocommerce hooks with thumbnail regenerate plugin but still have same issue i didn't see any changes in my website i removed cache as well.
add_filter( 'woocommerce_get_image_size_gallery_thumbnail', 'override_woocommerce_image_size_gallery_thumbnail');
function override_woocommerce_image_size_gallery_thumbnail( $size ) {
// Gallery thumbnails: proportional, max width 200px
return array(
'width' => 100,
'height' => 100,
'crop' => 0,
);
}

I think the answer to that is in the "Appearance / Customize" then Woocommerce. There you can choose how products images are cropped.

Related

Thumbnail with Woocommerce

With you alls help I was able to the desire thumbnail on the main page and product category pages. I followed Appearance > Customize > WooCommerce > Product Image.
However, on the individual product page, those actions don't apply. I am still getting cropped images. Any help with suggestions/advice would be appreciated.[enter
Try to add this in your child theme’s functions.php
add_filter( 'woocommerce_get_image_size_gallery_thumbnail', function( $size ) {
return array(
'width' => 150,
'height' => 150,
'crop' => 0,
);
});

showing 12 items instead of 16 on WordPress / Woocommerce page

i have a WordPress site using Avada theme, and Woocommerce. The products categories pages will show 16 items at a time. My issue is that the sidebar's existence means the products are 3 in a row, and this causes the last row to only have 1 product. This can lead the user to think there aren't anymore pages.
I need to show 12 items instead of 16, and that will fix me! I am comfortable editing theme files / CSS. I was hoping for insight to the best way. Thanks!
https://paramedsupply.com/product-category/blood-collection/
it was in Avada > Woocommerce settings! I just found it. I had assumed it wouldn't be that easy!
For anyone else having this problem with other themes and can't seem to override any display settings.
You could declare the following WooCommerce theme support arguments:
function mytheme_add_woocommerce_support() {
add_theme_support( 'woocommerce', array(
'thumbnail_image_width' => 150,
'single_image_width' => 300,
'product_grid' => array(
'default_rows' => 3,
'min_rows' => 2,
'max_rows' => 8,
'default_columns' => 4,
'min_columns' => 2,
'max_columns' => 5,
),
) );
}
add_action( 'after_setup_theme', 'mytheme_add_woocommerce_support' );

Resizing WooCommerce images

using WooCommerce I put this snippet in function.php to define the size of images overwriting the panel settings :
function yourtheme_woocommerce_image_dimensions() {
$single = array(
'width' => '400', // px
'height' => '300', // px
'crop' => 1 // true
);
$thumbnail = array(
'width' => '180', // px
'height' => '135', // px
'crop' => 1 // false
);
$catalog = array(
'width' => '140', // px
'height' => '105', // px
'crop' => 1 // true
);
// Image sizes
update_option( 'shop_single_image_size', $single ); // Single product image
update_option( 'shop_thumbnail_image_size', $thumbnail );
update_option( 'shop_catalog_image_size', $catalog ); // Product category thumbs
All works fine but now I'd like to set different image sizes relating to $catalog just in single product page (where there's a widget showing that images).
I've tried with conditional statements, cause I don't want to use css tricks, but without luck.
Any help will be appreciate.
Thank you.
Did you re-generate the thumbnails after changing the size? If no, than try force regenerate thumbnails plugin to re-generate images that will have new sizes. When indicating new size in Wp functions, than it will affect new uploads but you also need to regenerate new sizes for previously uploaded ones.

Set size and crop thumbnail in custom WordPress theme

Setting the size for a thumbnail is not a problem, but I also want to crop the image from top and to the left, but it's not working!
Inside functions.php I have this code:
function theme_setup() {
register_nav_menus(array(
'primary' => __('Main Menu'),
'footer' => __('Footer Menu'),
));
add_theme_support('post-thumbnails');
add_image_size('thumbnail', 300, 300, true);
add_image_size('post', 800,400, true);
}
add_action('after_setup_theme', 'theme_setup');
I have tested to add this code inside the function:
add_image_size('thumbnail', 300, 300, array( 'top', 'left'));
But it's not cropping from top left. All thumbnails are cropped center center
I saw this code on the WordPress Codex page:
set_post_thumbnail_size( 300, 300, array( 'top', 'left') );
If I should use this insted, how should I add this in functions.php to get it to work? I just tested to paste it in the code, but it's not working that either!
Any ideas why my code isn't working or suggestion how to improve the code?
EDIT: I forgot to write that I also has used the plugin Regenerate Thumbnails before I have changed the settings for the thumbnails.

wordpress ignores featured image

I created a wordpress theme based on the classic twentyten theme.
I changed the size of the header images in the functions.php but apart from that I didnt mess around with the custom header stuff. Now wordpress is ignoring it when I assign featured images to pages and instead only displays the background selected in the header settings.
The size of the image doesnt seem to have anything to do with the problem. I have tried using the exact image size and larger images, they are always ignored...
Thanks if you can help!
PS. Here a link to the website: http://stuck-mueller.de/beta/
here is the code from the functions.php:
// The custom header business starts here.
$custom_header_support = array(
// The default image to use.
// The %s is a placeholder for the theme template directory URI.
'default-image' => '%s/images/headers/path.jpg',
// The height and width of our custom header.
'width' => apply_filters( 'twentyten_header_image_width', 960 ),
'height' => apply_filters( 'twentyten_header_image_height', 240 ),
// Support flexible heights.
'flex-height' => true,
// Don't support text inside the header image.
'header-text' => false,
// Callback for styling the header preview in the admin.
'admin-head-callback' => 'twentyten_admin_header_style',
);
add_theme_support( 'custom-header', $custom_header_support );
if ( ! function_exists( 'get_custom_header' ) ) {
// This is all for compatibility with versions of WordPress prior to 3.4.
define( 'HEADER_TEXTCOLOR', '' );
define( 'NO_HEADER_TEXT', true );
define( 'HEADER_IMAGE', $custom_header_support['default-image'] );
define( 'HEADER_IMAGE_WIDTH', $custom_header_support['width'] );
define( 'HEADER_IMAGE_HEIGHT', $custom_header_support['height'] );
add_custom_image_header( '', $custom_header_support['admin-head-callback'] );
add_custom_background();
}
// We'll be using post thumbnails for custom header images on posts and pages.
// We want them to be 940 pixels wide by 198 pixels tall.
// Larger images will be auto-cropped to fit, smaller ones will be ignored. See header.php.
set_post_thumbnail_size( $custom_header_support['width'], $custom_header_support['height'], true );
You don't need the apply_filters() just assign the width and height to integers like:
'width' => 960,
'height' => 240,
Check out the codex here for more info

Resources