WC_Product_CSV_Importer::parse_images_field()publicWC 1.0

Parse images list from a CSV. Images can be filenames or URLs.

Метод класса: WC_Product_CSV_Importer{}

Хуки из метода

Возвращает

Массив.

Использование

$WC_Product_CSV_Importer = new WC_Product_CSV_Importer();
$WC_Product_CSV_Importer->parse_images_field( $value );
$value(строка) (обязательный)
Field value.

Код WC_Product_CSV_Importer::parse_images_field() WC 8.7.0

public function parse_images_field( $value ) {
	if ( empty( $value ) ) {
		return array();
	}

	$images    = array();
	$separator = apply_filters( 'woocommerce_product_import_image_separator', ',' );

	foreach ( $this->explode_values( $value, $separator ) as $image ) {
		if ( stristr( $image, '://' ) ) {
			$images[] = esc_url_raw( $image );
		} else {
			$images[] = sanitize_file_name( $image );
		}
	}

	return $images;
}