' . file_get_contents(WP_CONTENT_DIR . '/agent-connector-for-wp-sandbox/tbm-vikan-media.php')); // $id = $import($perfion_id, '56863', $post_id, 'Vedro, 12 litrov – modré', 'Modré hygienické vedro Vikan 12 l'); defined('ABSPATH') || exit; require_once ABSPATH . 'wp-admin/includes/file.php'; require_once ABSPATH . 'wp-admin/includes/media.php'; require_once ABSPATH . 'wp-admin/includes/image.php'; return function ($perfion_id, $name, $post_id, $title, $alt) { $url = 'https://perfion.vikan.com/perfion/image.aspx?id=' . strtoupper($perfion_id) . '&format=jpg'; $map = get_option('tbm_vikan_media', []); if (isset($map[$url]) && get_post($map[$url])) return $map[$url]; $tmp = download_url($url, 60); if (is_wp_error($tmp)) return 0; try { $img = new Imagick($tmp); $img->setImageBackgroundColor('white'); $img = $img->mergeImageLayers(Imagick::LAYERMETHOD_FLATTEN); $img->thumbnailImage(1380, 1380, true); $canvas = new Imagick(); $canvas->newImage(1500, 1500, 'white', 'jpg'); $canvas->compositeImage($img, Imagick::COMPOSITE_OVER, (int) ((1500 - $img->getImageWidth()) / 2), (int) ((1500 - $img->getImageHeight()) / 2)); $canvas->setImageCompressionQuality(85); $canvas->writeImage($tmp); } catch (Exception $e) { @unlink($tmp); return 0; } $id = media_handle_sideload(['name' => "vikan-$name-sq.jpg", 'tmp_name' => $tmp], $post_id, $title); if (is_wp_error($id)) { @unlink($tmp); return 0; } update_post_meta($id, '_wp_attachment_image_alt', $alt); $map[$url] = $id; update_option('tbm_vikan_media', $map, false); return $id; }; https://www.techbm.sk/post-sitemap.xml 2026-09-23T13:57:09+00:00 https://www.techbm.sk/page-sitemap.xml 2026-10-21T15:05:50+00:00 https://www.techbm.sk/attachment-sitemap.xml 2026-10-19T07:15:28+00:00 https://www.techbm.sk/attachment-sitemap2.xml 2026-10-17T11:25:41+00:00 https://www.techbm.sk/attachment-sitemap3.xml 2026-10-19T07:15:28+00:00 https://www.techbm.sk/product-sitemap.xml 2026-10-19T15:37:11+00:00 https://www.techbm.sk/category-sitemap.xml 2026-09-23T13:57:09+00:00 https://www.techbm.sk/product_cat-sitemap.xml 2026-10-19T15:37:11+00:00 https://www.techbm.sk/product_tag-sitemap.xml 2026-10-19T15:37:11+00:00 https://www.techbm.sk/author-sitemap.xml 2024-02-09T16:03:26+00:00