-
AuthorPosts
-
June 19, 2016 at 10:19 pm #650513
Hi,
I would like to enable the category image thumbnail so it displays on the individual category to the left of the text field. I did this one on Abundance theme.
I tried with this code and it broke the page but had an undesirable effect on the page:
/* -------------------------------------------------------------- ## >= Display Category Images ----------------------------------------------------------------- */ add_action( 'woocommerce_archive_description', 'woocommerce_category_image', 2 ); function woocommerce_category_image() { if ( is_product_category() ){ global $wp_query; $cat = $wp_query->get_queried_object(); $thumbnail_id = get_woocommerce_term_meta( $cat->term_id, 'thumbnail_id', true ); $image = wp_get_attachment_url( $thumbnail_id ); if ( $image ) { echo '<div class="product-category-image"><img src="' . $image . '" alt="" /></div>'; } } }
June 21, 2016 at 3:36 am #651195Hey Vincent,
Thank you for using Enfold.
Please remove the modification then go to the Enfold > Shop Options. Enable the “Main Shop Page Banner” and then tick “Enable Banner for product category pages” option. You can now add featured image in the product categories.
Best regards,
IsmaelJune 21, 2016 at 11:55 am #651419Hi Ismael,
Thanks for your reply. Unfortunately, that is not what I meant.
I don’t want the banner image on each category. I want to use the thumbnail image so that it places directly to the left of the content on the category pages.
Here are two examples of websites that use this:
Bathrooms site: http://bathrooms.plus/z/showers/ (Notice the category thumbnail displays on the page).
Manscape site: (Abundance theme): http://www.manscape.co.uk/a/skincare/eye-care/ (The same, category thumbnail appears on page).Thanks
VincentJune 22, 2016 at 9:35 pm #652372Hi,
I have part of the solution which is to add the following to the functions.php. However, it needs to be resized with the following CSS. The only problem with this is it pushes the thumbnail to the extreme left into the sidebar. I have now removed the code and asking for support here.
Thanks
Vincentadd_action( 'woocommerce_archive_description', 'woocommerce_category_image', 2 ); function woocommerce_category_image() { if ( is_product_category() ){ global $wp_query; $cat = $wp_query->get_queried_object(); $thumbnail_id = get_woocommerce_term_meta( $cat->term_id, 'thumbnail_id', true ); $image = wp_get_attachment_url( $thumbnail_id ); if ( $image ) { echo '<div class="product-category-image"><img src="' . $image . '" alt="" /></div>'; } } }
CSS for thumbnail to left:
.product-category-image { max-width: 200px; float: left; margin-right: 1em; }
June 23, 2016 at 4:30 am #652443Hi,
You don’t need to add the modification. Edit the product category, add the description and the featured image. Make sure that the Display type is set to “Default” then use this in the Quick CSS field:
.tax-product_cat .page-thumb { float: left; width: 30%; } .tax-product_cat .term-description { float: left; width: 68%; clear: none; margin-left: 2%; }
Best regards,
IsmaelJune 23, 2016 at 3:42 pm #652627Hi Ismael that did not work either and made no difference. See category below:
yhanks Vincent
June 27, 2016 at 4:01 pm #653836Hi,
I added the image inside your description field.
Let us know if you are happy now.Best regards,
AndyJune 27, 2016 at 4:30 pm #653866Hi Andy,
I was already of that solution, however, it’s not optimum. Now we are adding as second layer of images, why not just draw through the actual category thumbnail? It should work on Woocommerce as it does on Abundance theme.
The code I sued in my response to Ismael works to place it on the page but breaks on positioning.
Thanks
VincentJune 28, 2016 at 1:43 pm #654203Hi,
it does work? if yes where is it? I can’t see it and I can only see the image from the description field.
Best regards,
AndyJune 28, 2016 at 3:31 pm #654257Hi,
I am not going to add that code back to the site as it keeps breaking it and slowing down this project.
All I want is the thumbnail that is added in the category to display on the page. This is not unusual and is normal practice.It works on abundance here: http://www.manscape.co.uk/a/skincare/
This works on the Woo commerce platform in which I provided code above, however, for some reason it breaking Enfold. Is there any other person on this forum from Enfold that knows how to enable this?
Thanks
Vincent
July 2, 2016 at 1:41 am #655947Hi,
Did you try our previous solution? https://kriesi.at/support/topic/enable-display-of-category-image-on-shop/#post-652443
Best regards,
IsmaelJuly 3, 2016 at 1:39 pm #656256Hi Ismael,
I hope you don’t mind me asking, but why do you keep insisting that I use the code you supplied, it is already in there and it’s not working. I set the categories to default. For example: http://mens.boutique/z/fragrance/ and then I used this code:
/* ————————————————————
## >= Enable Archive Image Shop
—————————————————————-*/
.tax-product_cat .page-thumb {
float: left;
width: 30%;
}.tax-product_cat .term-description {
float: left;
width: 68%;
clear: none;
margin-left: 2%;
}It still does not work. The image does not pull through.
Thanks
Vincent- This reply was modified 8 years, 5 months ago by Vincent.
July 7, 2016 at 6:39 am #657837Hey!
The category image is positioned to the left and the description beside it. Isn’t that what you want? Maybe a screenshot will help. We tried to access the site but we are can’t get in.
Your access to this site has been limited
Your access to this service has been temporarily limited. Please try again in a few minutes. (HTTP response code 503)
Reason: Blocked by login security setting.Best regards,
IsmaelJuly 7, 2016 at 10:55 am #657883Hi Ismael
Please see notes in private area:July 10, 2016 at 8:11 am #658901Hi,
Thank you for the info. It is hidden because of this custom css code:
.page-thumb { display: none; }
You can remove that or just add the following code below:
.tax-product_cat .page-thumb { display: block; }
Check this archive page afterwards: http://mens.boutique/z/fragrance/
Best regards,
IsmaelJuly 10, 2016 at 11:51 am #658929Hi Ismael,
I see what you mean. The code .page-thumb {
display: none;
}
was there to prevent featured images showing on posts and pages from the featured image field.I have now added your code to the custom CSS http://mens.boutique/z/fragrance/ which displays the thumbnail. There is a stark difference between:
http://mens.boutique/z/fragrance/
and
http://mens.boutique/z/skincare/scrub/Whereas on some pages it is resizing correctly on other pages it chops off. Is there a specific size for this or is there a error in its resizing? I am using this whole piece here including your code:
/* ------------------------------------------------------------ ## >= Enable Archive Image Shop ----------------------------------------------------------------*/ .tax-product_cat .page-thumb { display: block; } .tax-product_cat .page-thumb { float: left; width: 30%; } .tax-product_cat .term-description { float: left; width: 68%; clear: none; margin-left: 2%; }
Thanks for your help, it looks much better now, I appreciate it.
Vincent
July 13, 2016 at 4:34 am #660186Hi,
The thumbnail size is set to the “entry_with_sidebar” which has a maximum dimension of 845x321px. Upload images within that size range or better yet, make sure to upload images with the same size and dimension.
You can also adjust the thumbnail size with the following plugin then regenerate the thumbnails: https://wordpress.org/plugins/simple-image-sizes/
Best regards,
IsmaeloJuly 13, 2016 at 5:26 pm #660509Cheers Ismael, please consider this resolved.
Thanks
Vincent -
AuthorPosts
- The topic ‘Enable Display of Category Image on Shop’ is closed to new replies.