woocommerce_get_alt_from_product_title_and_position()
Get alt text based on product name and image position in gallery.
Хуков нет.
Возвращает
Строку
. Alt text.
Использование
woocommerce_get_alt_from_product_title_and_position( $product_name, $main_image, $image_index );
- $product_name(строка) (обязательный)
- Product name.
- $main_image(true|false) (обязательный)
- Is this the main image or a thumbnail?.
- $image_index(int) (обязательный)
- Image position in gallery.
Список изменений
С версии 9.3.3 | Введена. |
Код woocommerce_get_alt_from_product_title_and_position() woocommerce get alt from product title and position WC 9.8.2
function woocommerce_get_alt_from_product_title_and_position( $product_name, $main_image, $image_index ) { if ( -1 === $image_index ) { return $product_name; } $adder = $main_image ? 1 : 2; /* translators: 1: product name 2: image position */ return sprintf( __( '%1$s - Image %2$s', 'woocommerce' ), $product_name, ( $image_index + $adder ) ); }