/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function insert_image($inserted_product, $product_id){ $image_url = $inserted_product["url"]; switch($file_extension){ case "jpeg": break; case "jpg": break; case "gif": break; case "png": break; case "bmp": break; } $color_compression = 65; $org_width = $bigger_image_size[0]; $org_height = $bigger_image_size[1]; $widthSmall = 75; $heightSmall = ($widthSmall / $org_width) * $org_height; $widthBigger = 250; $heightBigger = ($widthBigger / $org_width) * $org_height; $dir = '../shops/'.$inserted_product["shop_id"].'/products/'.$product_id.'/'; create_folder($dir); $small_path = $dir.$inserted_product["slug"].'_lille.jpg'; $bigger_path = $dir.$inserted_product["slug"].'_stor.jpg'; imagecopyresampled($small_image, $image_source, 0, 0, 0, 0, $widthSmall, $heightSmall, $org_width, $org_height); imagecopyresized($bigger_image, $image_source, 0, 0, 0, 0, $widthBigger, $heightBigger, $org_width, $org_height); } function create_folder($path) { $lastPath = ''; foreach ($structure as $folder) { if ($lastPath) { $folder = $lastPath.'/'.$folder; } } $lastPath = $folder; } }