Thumbnail with Woocommerce - wordpress

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,
);
});

Related

Woocommerce single product gallery images cropped

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.

How can I make the user change any image on my wp theme just from the theme editor?

How can I make the user change any image on my wp theme just from the theme editor?
For example: I have a background image on my theme footer that i hard-coded, I want to give the user(admin) the ability to change it from the theme editor, and thanks on advanced
I don't want to use something like this:
<div class="footer-background background-image" style="background-image: url(<?php echo get_theme_file_uri( 'assets/images/bg.jpg' ) ?>)" >
If you can just give me a wp codex on this, it would be more than helpful, because I couldn't find any thing related to my problem on Google.
So, you could do something like that (in functions.php) :
add_action( 'customize_register', function( $wp_customize ) {
$wp_customize->add_section(
'section_img',
array(
'title' => 'Images',
'priority' => 35,
)
);
$wp_customize->add_setting(
'footer_image'
);
$wp_customize->add_control(
new WP_Customize_Image_Control(
$wp_customize,
'footer_image',
array(
'label' => 'Footer image',
'section' => 'section_img',
'settings' => 'footer_image'
)
)
);
});
And you get the value by doing (in footer.php) :
get_theme_mod('footer_image');
If I were you, I do followings
Install ACF plugin
Create an option Page
Create new custom field (image field) and assign it to previously created options page.
Update footer template to show the image from back end like this
Update footer image src to get back end ACF field value.
https://www.advancedcustomfields.com/resources/options-page/
https://www.advancedcustomfields.com/resources/image/

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' );

How to set a custom image size for single product image for a specific category in woocommerce ( prior to 3.0 )?

I need to set a custom product image size for a specific category of products in woocommerce. The default is set to 300x300 px in woocommerce single product image settings but need it to be 600x600 px for specific category of products.
Use Theme support codes in your functions.php files
<?php add_theme_support( 'woocommerce', array(
'thumbnail_image_width' => 150,
'single_image_width' => 322,
) ); ?>

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.

Resources