Custom taxonomy image for a single featured image product - image

I need to change all featured image products with the images of the term of taxonomy.
I tried this code and I have the right image taxonomy on a single page but does not replace the featured image of the product.
The name of my taxonomy is "settore"
Can you help me, please?
Have a great day
add_action("woocommerce_before_add_to_cart_form","product_taxonomy_image");
function product_taxonomy_image () {
print apply_filters( 'taxonomy-images-list-the-terms', '', array(
'before' => '<div class="my-custom-class-name">',
'after' => '</div>',
'before_image' => '<span>',
'after_image' => '</span>',
'image_size' => 'detail',
'taxonomy' => 'settore',
) );
}

Related

Get sku and product image in woocommerce emails

I made a copy of the file "email-order-details.php" to my child theme. Now I can modify the html, but would like to add an extra column to my table for the product image. With this code I am able to display the image and sku, but it's in the same column with product name, sku, product description.
<?php
echo wc_get_email_order_items( $order, array( // WPCS: XSS ok.
'show_sku' => $true,
'show_image' => false,
'image_size' => array( 32, 32 ),
'plain_text' => $plain_text,
'sent_to_admin' => $sent_to_admin,
) );
?>
I also want to display the sku without the () and I want to place it on top of the column. I think there must be an array or variables or something like this to get the dates.
This line, for example displays the Price, can anybody tell me how to display sku and product image in the same way?
<th class="td" scope="col" style="text-align:<?php echo esc_attr( $text_align ); ?>;"><?php esc_html_e( 'Price', 'woocommerce' ); ?></th>
Thank you in advance
try this snippet code, I use this in functions.php in child theme:
function sww_add_wc_order_email_images( $table, $order ) {
ob_start();
$template = $plain_text ? 'emails/plain/email-order-items.php' : 'emails/email-order-items.php';
wc_get_template( $template, array(
'order' => $order,
'items' => $order->get_items(),
'show_download_links' => $show_download_links,
'show_sku' => $show_sku,
'show_purchase_note' => true,
'show_image' => true,
'image_size' => array( 200, 200 )
) );
return ob_get_clean();
}
add_filter( 'woocommerce_email_order_items_table', 'sww_add_wc_order_email_images', 10, 2 );

Include Sidebar Generator plug-in into my WP theme

I'm trying to include this plug-in:
http://wordpress.org/extend/plugins/sidebar-generator/
Into my wordpress theme. As many people around the internet said, I just included the sidebar_generator.php file into my functions.php. The 'Sidebars' menu appears under appearance, but no matter what I do, If I click on it nothing happens (just like it was linked on a '#').
If I install the plug-in through the wordpress interface everything works, I need to have it integrated though.
Any help?
Thank you
You shouldn't need a plugin to have extra sidebars. You should be able to build a theme template with as many sidebars as you want. When I'm creating a custom theme in WordPress I use a variation of the 960 CSS Grid (another good one is the newer 1140px CSS Grid System, which is fluid).
To register your sidebars to accept widgets, insert this code in your functions.php file:
// Widget Areas //
if ( function_exists('register_sidebars') ) {
// Primary sidebar widget
register_sidebar( array(
'name' => __( 'Blog Sidebar', 'unique' ),
'id' => 'blog-sidebar',
'description' => __( 'The sidebar widget area for the blog.', 'unique' ),
'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
'after_widget' => '</li>',
'before_title' => '<h2 class="widget-title">',
'after_title' => '</h2>',
) );
register_sidebar( array(
'name' => __( 'Left Sidebar', 'unique' ),
'id' => 'left-sidebar',
'description' => __( 'The left sidebar widget area for pages.', 'unique' ),
'before_widget' => '<li id="%1$s" class="greenGradient widget-container %2$s">',
'after_widget' => '</li>',
'before_title' => '<h2 class="widget-title greenbar center">',
'after_title' => '</h2>',
) );
register_sidebar( array(
'name' => __( 'Right Sidebar', 'unique' ),
'id' => 'right-sidebar',
'description' => __( 'The right sidebar widget area for pages.', 'unique' ),
'before_widget' => '<li id="%1$s" class="redGradient widget-container %2$s">',
'after_widget' => '</li>',
'before_title' => '<h2 class="widget-title redbar center">',
'after_title' => '</h2>',
) );
}
In this case, I have a registered sidebar for just the blog, then one each for a right sidebar and a left sidebar.
In my theme directory I have three sidebar.php files. The blog sidebar file is the default sidebar.php file. The other two are named sidebar-left.php and sidebar-right.php. Each sidebar has it's appropriate code as follows:
<?php // blog widget area
if ( is_active_sidebar( 'blog-sidebar' ) ) : ?>
<ul>
<?php dynamic_sidebar( 'blog-sidebar' ); ?>
</ul>
<?php endif; // end blog widget area ?>
Wrap this code inside your divs in the sidebar and be sure you change the 'blog-sidebar' name to the one for each sidebar.
Looking for function admin_menu and edit in that line. Just replace __FILE__ by sidebar-generator.
Interpretation: If you use sidebar generator as a plugin, __FILE__ means sidebar-generator, but if you include it in some directory of your themes, the constant __FILE__ may change to something different (such as inc, includes... or something else)

MAGENTO : Add image field in custom module

I'm creating a module and i want to add a picture in the edit page (back office), i do this :
$fieldset->addField('photo', 'image', array(
'label' => "image",
'required' => false,
'name' => 'image',
));
the input is present in the page but in my controller i don't have any information about this picture, does someone can tell me how i can do this ?
Thanks.
Refer the image upload article
http://www.magentocommerce.com/wiki/5_-_modules_and_development/admin/how_to_create_pdf_upload_in_backend_for_own_module

Wordpress - changing attributes of featured images

I want to use Featured Images (thumbnails) in my posts.
The thing is, I want to be able to change the following image attributes after the image has been attached to the post, but before the post has been published:
Title
Alternate Text
Caption
Description
How do you do that?
<?php
$size = array(150,150);
$default_attr = array(
'src' => $src,
'class' => "attachment-$size",
'alt' => trim(strip_tags( wp_postmeta->_wp_attachment_image_alt )),
'title' => trim(strip_tags( $attachment->post_title )),
);
the_post_thumbnail( $size, $attr );
?>
I'm still not clear what you're trying to do.
This will display the featured image in your markup using the post title as alt and title attributes.
$image_meta = wp_get_attachment_image_src( get_post_thumbnail_id(), 'medium');
// replace 'medium' with 'thumbnail', 'large', or 'full'.
echo '<img src="'.$image_meta[0].'" alt="'.$post->post_title.'" title="'.$post->post_title.'" width="'.$image_meta[1].'" height="'.$image_meta[2].'"/>';
If you want to actually change the featured image title, alt, caption, description etc in the database, then you could look at the post_publish hook. This should get you started:
function do_stuff($post_ID){
global $post;
$post_thumbnail_id = get_post_thumbnail_id($post_ID);
if ($post_thumbnail_id){
// Do Stuff with your featured image id - $post_thumbnail_id
}
return $post_ID;
}
add_action('publish_post', 'do_stuff');
try this and its work fine.
$title_attribute = the_title_attribute( array( 'echo' => FALSE ) );
the_post_thumbnail(
'full',
array(
'alt' => $title_attribute,
'title' => $title_attribute
)
);

How to get and set image attachment metadata in wordpress?

I have post in WP. This post has attached image as attachment. I set description of this image via dialog (gallery tab) in post edit section.
Now I need WP functions to programmatically get all metadata for this attachment (description,title,caption,...) and another function to set the same data.
What functions to use ?
use get_children() to retrive atachement for posts.
$args = array(
'numberposts' => -1,
'order'=> 'ASC',
'post_mime_type' => 'image',
'post_parent' => $post->ID,
'post_status' => null,
'post_type' => 'attachment'
);
$attachments = get_children( $args );
a full example here Get URLs, Captions & Titles for Images Attached to Posts in WordPress
This works for me:
<?php
foreach ( $attachments as $attachment_id => $attachment ) {
$src = wp_get_attachment_image_src( $attachment_id, 'full' );
var_dump($src);
} ?>
array
0 => string 'http://example.com/wp-content/uploads/2009/08/DSC00261.JPG' (length=63)
1 => int 1632
2 => int 1224
3 => boolean false
The order of the array is allocated as follows.
$src[0] => url
$src[1] => width
$src[2] => height
$src[3] => icon

Resources