関数
Utils::getSkuImageLinks( int $skuMetaId )
パラメータ パラメータ
- $skuMetaId
(数値) (必須)
ファイル: src/Utils.php
public static function getSkuImageLinks($skuMetaId) {
global $wpdb, $usces;
$defaultres = [
'fullSizeLink' => '',
'thumbnailLink' => '',
];
$data = $wpdb->get_row(
$wpdb->prepare(
"SELECT * FROM {$wpdb->postmeta} WHERE meta_id = %d AND meta_key = '_isku_'",
(int)$skuMetaId
),
ARRAY_A
);
if (empty($data)) {
return $defaultres;
}
$skudata = unserialize($data['meta_value']);
if (empty($skudata)) {
return $defaultres;
}
$imgid = $usces->get_subpictid($skudata['code']);
if (empty($imgid)) {
$imgid = $usces->get_mainpictid($usces->getItemCode($data['post_id']));
}
$imgid = !empty($imgid) ? $imgid : 0;
return [
'fullSizeLink' => wp_get_attachment_image_src($imgid, 'full-size', true),
'mediumSizeLink' => wp_get_attachment_image_src($imgid, 'medium', true),
'thumbnailLink' => wp_get_attachment_image_src($imgid, 'thumbnail', true),
];
}