woocommerce - insert video into product gallery slider - wordpress

I'm trying to insert an embed video(youtube) into the product galley slider that appears on product page.
So far i'm working with
add_filter('woocommerce_single_product_image_thumbnail_html','my function');
to add the video thumb but i don't know what are the filters to add the new content in woocommerce-product-gallery div (where the larger images are) or in the light box .
Also the 'woocommerce_single_product_image_thumbnail_html' hook runs after each thumb so it will be nice if i would use a filter that runs before/after the thumbs are displayed. I've try to use
add_action( 'woocommerce_product_thumbnails', 'my_function', 20 );
but it does not work.
So the question is : what are the hooks i need to use to add new thumbs and new slides in the woocommerce product slider.
Thank you.

Related

Woocommerce - Move titles over thumbnails of products in Category page

I need to move the titles of the products, while I am browsing the category page, over their thumbnails
Details:
I have created a shop page where I only display the categories.
Every category contains 1 to 10 products.
Once I click a category, I land on a page where I see all of the products in that category.
I would like to see the titles of those products appearing over their thumbnails.
Thank you
A few more details relating to your parituclar setup are needed to give a proper answer. However, I'm going to assume you have everything at default. This is what you would need to add to the end of functions.php in your active theme folder:
remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10 );
add_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10 );
For reference, check https://github.com/woothemes/woocommerce/blob/master/templates/content-product.php and https://github.com/woothemes/woocommerce/blob/master/includes/wc-template-hooks.php
If this does not work, check:
that you use the latest version of woocommerce. Actually a few versions back should work the same, but not too far back.
that your woocommerce templates are not overwritten. Check your theme folder for a file called content-product.php or in a subfolder woocommerce/content-product.php. If that has been altered, you need to adjust accordingly, perhaps by making changes right there.
that your theme does not already mess around with product display hooks. If it does, find out what's different.
Please note that this changes behavior for all woocommerce loops, such as any shortcodes you might be using and the "related products" section in single product view, if that is enabled. To affect only categories, the changes should be wrapped in a condition check ( is_product_category() ).
If you put code into a plugin, you must wait for WooCommerce loading:
add_action('plugins_loaded', function()
{
// move product's title before product thumbnail instead of next to that
remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_title', 5);
add_action('woocommerce_before_single_product_summary', 'woocommerce_template_single_title');
}
Added this CSS for the product title and it worked fine for me. I used media query of course.
position: absolute;
top: 0px;

Woocommerce add click to enlarge under featured image

I'm using Woocomerce (Wootique) and I'd like to add "Click To Enlarge Image" beneath the featured image on single product page. Text should show beneath image and above the description/reviews tabs.
Can't figure it out? Any ideas?
http://www.forgottentreasurez.us/product/hand-signed-limited-edition-serigraph-mazal-tov-love/
Thank you in advance
There’s an action that you can use to add content below featured images, which can be used before or after product thumbnails. The woocommerce_product_thumbnail action is what will help us out. Let’s add a notice that says, “Click to Enlarge” below the featured image.
We’ll use a function to insert this text as a heading below the featured image. You can add this to your child theme or, even better, a code snippet using the Code Snippet plugin.
function skyverge_add_below_featured_image() {
echo '<h4 style="text-align:center;margin-top:10px;">Click to Enlarge</h4>';
}
add_action( 'woocommerce_product_thumbnails' , 'skyverge_add_below_featured_image', 9 );

Limit number of images in a nextgen gallery

I am using the nextgen gallery plugin for WordPress. I am making a page in which I want to get the nextgen gallery by id and limit the number of images in it to 2. The code I am using to get the gallery is:
$post_id = get_the_ID();
$gallery = get_post_meta (get_the_ID(), 'Gallery', false);
$successes = $gallery[0]; /* Where $array is the variable holding the result */
$gallery_id= $successes[0];
echo do_shortcode('[nggallery id='.$gallery_id.']');
There are six images in the gallery and they are used in the original post. This is just a tour post so I want to limit the number of pictures here. Is this possible?
You can try the following shortcodes:
1.
echo do_shortcode("[nggallery id=$gallery_id images=2]");
the images parameter controls the number of displayed images. 0 means show all. You will also get some pagination links to navigate through gallery's images. I haven't found an option to hide them, so if they are unnecessary you can hide them via css (display: none).
2.
echo do_shortcode("[random max=2 id=$gallery_id]");
which displays randomly maximum 2 pictures from your gallery.
I also recommend the following links:
NextGEN Gallery Shortcodes, var 2.0 and up:
http://www.nextgen-gallery.com/nextgen-gallery-shortcodes/
NextGEN Legacy Shortcodes:
http://www.nextgen-gallery.com/help/shortcodes/
Undocumented NextGEN Gallery shortcodes:
http://www.ralph-kemps.eu/2013/03/19/undocumented-nextgen-gallery-shortcodes/

Different thumbnails sizes for different custom post types, and creating thumbnails for featured images only

I've got a wordpress site with a few custom post types. Each custom post type shows a list page, basically displaying a featured image and a title, and then you can click through to a detail page with a bunch more images.
I only need to resize uploaded "feature images". If an uploaded image isn't used as a feature image, I don't need a thumbnail for it. Furthermore, each custom post type shows a different sized feature image.
So, what I want to do is say:
a) Only create thumbnails for feature images
b) Create certain sizes for certain post types, and not for others.
Is this possible? At the moment, EVERY uploaded image is getting 5 thumbnail sizes, and my wp-content directory is WAAAY bigger than it needs to be!
Thanks in advance.
Ok I found a solution using the intermediate_image_sizes filter hook. Place this code in your functions.php and replace the 'post_type' and 'img_size_name' with the names of your post and desired image size.
add_filter( 'intermediate_image_sizes', function($sizes){
$type = get_post_type($_REQUEST['post_id']);
foreach($sizes as $key => $value){
if($type=='post_type' && $value != 'img_size_name'){
unset($sizes[$key]);
}
}
return $sizes;
});
To avoid waste of space, the best solution is to use phpthumb (http://phpthumb.sourceforge.net/) inside your page templates.

Setting thumbnail featured image size not working properly

Hi I just started today on creating my first Wordpress Theme and I am trying to create a featured Image for each post.Aldo I have managed to acomplish that it seems that the sizes I am giving it are not taking effect.Here is my code:
if(function_exists('add_theme_support')){
add_theme_support('post-thumbnails' , array('post'));
set_post_thumbnail_size(200,120);
}
if(function_exists('has_post_thumbnail') && has_post_thumbnail()){
the_post_thumbnail();
}
It seems that my featured images are not always set to the same size.For example if the image is smaller then what size I set it will remain the same , for big images the width is the same but for some the height is different.
What am I doing wrong here?
Are you setting the thumbnail size in functions.php? It will not work properly if it's just in index.php or another theme file.
From the codex:
This feature must be called before the init hook is fired. That means
it needs to be placed directly into functions.php or within a function
attached to the 'after_setup_theme' hook. For custom post types, you
can also add post thumbnails using the register_post_type function as
well.
the_post_thumbnail() displays the thumbnail and should be placed where you want the thumbnail to display.

Resources