Automattic\WooCommerce\Blocks\AIContent
UpdatePatterns::get_images_for_pattern()
Returns the images for the given pattern.
Метод класса: UpdatePatterns{}
Хуков нет.
Возвращает
Массив
. An array containing an array of the images in the first position and their alts in the second.
Использование
// private - только в коде основоного (родительского) класса $result = $this->get_images_for_pattern( $pattern, $selected_images ): array;
- $pattern(массив) (обязательный)
- The array representing the pattern.
- $selected_images(массив) (обязательный)
- The array of images.
Код UpdatePatterns::get_images_for_pattern() UpdatePatterns::get images for pattern WC 9.5.1
private function get_images_for_pattern( array $pattern, array $selected_images ): array { $images = array(); $alts = array(); foreach ( $selected_images as $selected_image ) { if ( ! isset( $selected_image['title'] ) ) { continue; } if ( ! isset( $selected_image['URL'] ) ) { continue; } if ( str_contains( '.jpeg', $selected_image['title'] ) ) { continue; } $expected_image_format = $pattern['images_format'] ?? 'portrait'; $selected_image_format = $this->get_selected_image_format( $selected_image ); if ( $selected_image_format !== $expected_image_format ) { continue; } $selected_image_url = ContentProcessor::adjust_image_size( $selected_image['URL'], 'patterns' ); $images[] = $selected_image_url; $alts[] = $selected_image['title']; } return array( $images, $alts ); }