function wcla_load_designer_iframe($atts) { global $woocommerce; $woocommerce->cart->set_quantity($_GET["cart_key"], 0); // . if (isset($_GET["design_id"])) { $url = site_url('/designer/') . '?design_id=' . (string) $_GET["design_id"]; } else { $url = site_url('/designer/') . '?productid=' . ((int) $_GET["productid"] == 0 ? (string) WCLA_Utilities::get_option('wcla_product_id') : (string) $_GET["productid"]); } echo '<iframe height="' . WCLA_Utilities::get_option('wcla_iframe_height') . '" width="' . WCLA_Utilities::get_option('wcla_iframe_width') . '" scrolling="yes" style="border:none;overflow:hidden;" src="' . $url . '"></iframe>'; }
public function generateImages($designId, $locations) { $image = array(); foreach ($locations as $location) { $baseSvg = $location->svg; $svg = $baseSvg; //$baseSvg = str_replace('NS1:', 'xlink:', $baseSvg); if (!is_array($images[$location->name])) { $images[$location->name] = array(); } $basePath = DESIGNER_DESIGNS_DIR . $designId . '/'; if (!file_exists($basePath)) { mkdir($basePath, 0777, true); } $baseSvgForConvert = $baseSvg; preg_match_all('|xlink:href="(.*)"|U', $baseSvgForConvert, $matches); if (isset($matches[1][0])) { $textImageIndex = 0; foreach ($matches[1] as $url) { if (strpos($url, DESIGNER_UPLOAD_URL) !== false) { $imagePath = str_replace(DESIGNER_UPLOAD_URL, DESIGNER_UPLOAD_DIR, $url); $imageFilename = pathinfo($imagePath, PATHINFO_BASENAME); copy($imagePath, $basePath . $imageFilename); $baseSvgForConvert = str_replace($url, $imageFilename, $baseSvgForConvert); } } } // Gallery images preg_match_all('|la-source-url="(.*)"|U', $baseSvgForConvert, $matches); if (isset($matches[1][0])) { foreach ($matches[1] as $url) { if (strpos($url, DESIGNER_UPLOAD_URL) !== false) { $imagePath = str_replace(DESIGNER_UPLOAD_URL, DESIGNER_UPLOAD_DIR, $url); $imageFilename = pathinfo($imagePath, PATHINFO_BASENAME); copy($imagePath, $basePath . $imageFilename); $baseSvgForConvert = str_replace($url, $imageFilename, $baseSvgForConvert); } } } // Replace fonts name to system fonts names (need for convertion) $fonts = new WP_Query(); $fonts->query(array('post_type' => 'wcla_fonts', 'nopaging' => true)); foreach ($fonts->posts as $font) { if (!get_post_meta($font->ID, 'wcla_font_system_name', true)) { continue; } $baseSvgForConvert = str_replace('"' . get_post_meta($font->ID, 'wcla_font_family', true) . '"', '"' . get_post_meta($font->ID, 'wcla_font_system_name', true) . '"', $baseSvgForConvert); $baseSvgForConvert = preg_replace('|font-family: [\']*' . get_post_meta($font->ID, 'wcla_font_family', true) . '[\']*;|U', 'font-family: ' . get_post_meta($font->ID, 'wcla_font_system_name', true) . ';', $baseSvgForConvert); } $imagePathSvg = $basePath . $designId . '_' . $location->name . '.svg'; $svgForConvert = $baseSvgForConvert; file_put_contents($imagePathSvg, $svgForConvert); $filename = $designId . '_' . $location->name; $convertMethod = WCLA_Utilities::get_option('wcla_convert_method'); //var_dump($convertMethod);die; if (WCLA_Utilities::get_option('wcla_enable_convert')) { switch ($convertMethod) { case 'imagick': //exec('convert ' . $imagePathSvg . ' -resize ' . $imageWidth . 'x' . $imageHeight . ' ' . $basePath . $filename . '.jpg', $output); exec('/usr/local/bin/convert ' . $imagePathSvg . ' ' . $basePath . $filename . '.jpg', $output); //echo 'inkscape --export-png=' . $basePath . $filename . '.png' . ' --export-background-opacity=0 --without-gui ' . $imagePathSvg; break; case 'inkscape': exec('inkscape --export-png=' . $basePath . $filename . '.png' . ' --export-background-opacity=0 --without-gui ' . $imagePathSvg, $output); exec('/usr/local/bin/convert ' . $basePath . $filename . '.png' . ' ' . $basePath . $filename . '.jpg', $output); break; } } unlink($imagePathSvg); // ************************ // Save svg file_put_contents($imagePathSvg, $svg); $images[$location->name]['svg'] = $filename . '.svg'; if (file_exists($basePath . $filename . '.jpg')) { $images[$location->name]['jpg'] = $filename . '.jpg'; } if (file_exists($basePath . $filename . '.png')) { $images[$location->name]['png'] = $filename . '.jpg'; } } return $images; }