Phew!
Here is the code for functions.php.
add_filter( 'woocommerce_single_product_image_thumbnail_html', 'change_alt_to_caption_gallery_images', 10, 2 );
function change_alt_to_caption_gallery_images ( $wc_get_gallery_image_html, $image_id ){
$caption = get_post_field( 'post_excerpt', $image_id );
if ( !empty($caption) && !empty($wc_get_gallery_image_html) ) {
$caption = str_replace( '"', "''", $caption );
$caption_repl="data-caption="" . $caption . '"';
$wc_get_gallery_image_html = preg_replace( '/data-thumb-alt="[^"]+"/', $caption_repl, $wc_get_gallery_image_html );
}
return $wc_get_gallery_image_html;
}
Related Posts:
- WooCommerce single products images doesn’t zoom on hover and doesn’t change clicking on gallery
- woocommerce image product add a class and data-src attributes
- Image is not displayed in overridden woocommerce email
- WordPress Twenty Seventeen header image size not responsive for mobile
- How to upload images from wordpress front-end (the first image must be thumbnail and the rest without first must be in gallery woocommerce product)
- How to delete 1000s of duplicated images in WordPress?
- Some images aren’t shown on wordpress after installation on host
- Add custom CSS class to product images
- Woocommerce product image [closed]
- How do I make the product image smaller on a WooCommerce product page?
- Updating product image
- Images not uploading on product page of woocommercr
- How to solve `Error getting remote image` in woocommerce rest api script?
- Images not showing on site – Even though they are there
- Delete product image using WooCommerce API?
- Set Post Thumbnail to external URL
- Correct method of reducing the number of images created by WP and Woo together
- How do I change the woocommerce product gallery to show all thumbnails instead of three at a time in a carousel?
- How to show image caption in Woocommerce gallery
- Titles with thumbnails in media library
- WordPress pointing animated GIF images with wrong file name upon upload (GIFs animation not working)
- Blurry product card image – rendered is 486×452 vs 300×279 in real image. Smaller versions being autocreated and served using srcset
- Export Woocomerce Image Product URL
- How do I get my image for my product to not be blurry
- WooCommerce get physical store address
- WordPress query through Products variation stock [closed]
- How to hook on a WooCommerce checkout field?
- Woocommerce – How to add 5 stars to all products to test design
- How can I override these WooCommerce widget cart button functions
- How to get woocomerce attributes thumbnail in PHP? [closed]
- Programmatically added variations not showing until clicking Update button
- How to automatically add and show all the product attributes when creating a new product
- Import products to WooCommerce by CSV page won’t open [closed]
- How can i change the design of product sizes [closed]
- Following migration from DEV to LIVE, woocommerce can’t checkout
- Removing height and width from images with a caption
- How to handle Woocommerce API credentials
- Woocommerce Shipping label just hangs
- Get product variation attribute titles – WooCommerce
- user password reset e-mail
- Extending the woocommerce product export functionality
- Woo Related Products How to override the plugin script?
- Line break on Product details [closed]
- Get specific values in Woocommerce Rest API
- Javascript error when adding an item to the cart [closed]
- Woocommerce: Complex query in pre_get_posts [closed]
- How can I get all the woocommerce api orders [closed]
- Is it possible to update the total price on the checkout page in woocommerce from a custom field
- Customize WooCommerce Add To Cart Form Name [closed]
- Remove WooCommerce block styles
- Can’t find a product by SKU
- Weird strange letters appeared in all website links [duplicate]
- password_reset doesnt work
- Woocommerce image sizes missing from Appearance › Customize but not declared by theme
- How can I reference external attachments without breaking core WordPress files?
- Check if a WooCommerce Order Item has a specific meta data key
- WooCommerce Cart Items
- Retrieve Data from Custom Endpoint
- Online wc-blocks-style.css rendering instead of the hosted wc-blocks-style.css
- Place image caption outside of figure tag (Gutenburg Image Markup)
- Broken link additional images after moving server
- I have 3 types of prices in WP and I need to change price for each specific user role using hooks
- How do I display only the relevant attributes?
- How to hide “Shipping” label from Woocommerce cart page
- How to add php variable inside wc_enqueue_js(‘jQuery’) function?
- Show menu order field in quick edit
- Adapt shipping surcharge code [closed]
- How to access product’s meta data when deleting a WooCommerce product?
- How to remove the Sub category product URL Woocommerce
- WC_Structured_Data Class Causing Needless Translation
- Placing Lock Icon on WooCommmerce “Place Order” Checkout Button (WordPress ‘ignoring’ Changes…)
- How to Sync Woocommerce and CRM via External API
- Add sale count next to star rating in woocommerce single product page
- Format number to 2 decimal places
- How do i display zip code options during checkout [closed]
- Woocommerce language isn’t default language
- How set variation after filter in WooCommerce?
- Does anyone know a crowdsourcing plugin that can support the following use case?
- How to invoice Woocommerce customer the remainder balance amount for additional items to an already paid order
- WooCommerce – Show different terms and conditions for different user roles
- Display product thumbnail in Woocommerce email notifications
- WordPress user ID prefix
- Remove link for Woocommerce product tags
- WooCommerce Class dosen’t exist
- How to make product free for some customers and paid for others?
- WooCommerce – different icons for product categories
- WordPress returning “XHR” even when access keys are used
- mydomain.com/wp-login redirects to wordpress.com/wp-login
- Thumb doubles the image file size
- Custom access given to Admin dashboard
- WooCommerce, after moving reviews tab to under product description. If pagination link is clicked description is hidden
- Is it possible to hide certain products from displaying in the search results
- WordPress Woocommerce product-category info on one line [closed]
- Woocommerce display price without formatting [closed]
- How to get products outside main loop in Woocommerce?
- WooCommerce shipping tax
- Login page so wide [closed]
- Problems using WooCommerce & Qstomizer
- Remove Ok Button when popup message
- how to get the current page endpoint