/** * Check detail image sizes ration * * @param array $image_data Image data * @param array $images Array with initial images */ function fn_image_zoom_check_image(&$image_data, &$images) { $precision = 80; $ratio_detailed = round(round($images['detailed']['image_x'] / $images['detailed']['image_y'] * $precision) / $precision, 2); $ratio_original = round(round($image_data['width'] / $image_data['height'] * $precision) / $precision, 2); if ($ratio_detailed != $ratio_original) { if ($ratio_detailed < $ratio_original) { $new_x = ceil($images['detailed']['image_y'] / $image_data['height'] * $image_data['width']); $new_y = $images['detailed']['image_y']; } else { $new_y = ceil($images['detailed']['image_x'] / $image_data['width'] * $image_data['height']); $new_x = $images['detailed']['image_x']; } $file_path = fn_generate_thumbnail($images['detailed']['relative_path'], $new_x, $new_y, false, true); /** * Post hook for check detail image sizes ration * @param string $file_path File path * @param array $image_data Image data * @param array $images Array with initial images */ fn_set_hook('image_zoom_check_image_post', $file_path, $image_data, $images); if ($file_path) { $image_data['detailed_image_path'] = \Tygh\Storage::instance('images')->getUrl($file_path); } } }
/** * Check detiled image sizes ration * * @param array $image_data Image data * @param array $images Array with initial images * @param $image_width Result image width * @param $image_height Result image height * @return boolean Always true */ function fn_image_zoom_image_to_display_post(&$image_data, &$images, &$image_width, &$image_height) { if (!empty($images['detailed']) && !empty($image_data['detailed_image_path'])) { $precision = 100; $ratio_detailed = round($images['detailed']['image_x'] / $images['detailed']['image_y'] * $precision) / $precision; $ratio_original = round($image_data['width'] / $image_data['height'] * $precision) / $precision; if ($ratio_detailed != $ratio_original) { if ($ratio_detailed < $ratio_original) { $new_x = ceil($images['detailed']['image_y'] / $image_data['height'] * $image_data['width']); $new_y = $images['detailed']['image_y']; } else { $new_y = ceil($images['detailed']['image_x'] / $image_data['width'] * $image_data['height']); $new_x = $images['detailed']['image_x']; } $image_data['detailed_image_path'] = fn_generate_thumbnail($images['detailed']['relative_path'], $new_x, $new_y, false); } } return true; }
public static final function getApiImageData($image_pair, $type = 'product', $image_type = 'icon', $params = array()) { if (empty($image_pair)) { return false; } if ($image_type == 'detailed' and !empty($image_pair['detailed_id']) or empty($image_pair['image_id']) or !empty($image_pair['image_id']) and empty($image_pair['icon'])) { $icon = isset($image_pair['detailed']) ? $image_pair['detailed'] : array(); $icon['image_id'] = $image_pair['detailed_id']; } elseif (!empty($image_pair['image_id'])) { $icon = $image_pair['icon']; $icon['image_id'] = $image_pair['image_id']; } if (isset($params['width']) && isset($params['height']) && !empty($icon['image_x']) && !empty($icon['image_y']) && $icon['image_x'] > 0 && $icon['image_y'] > 0 && ($icon['image_x'] > $params['width'] || $icon['image_y'] > $params['width'])) { $path = version_compare(PRODUCT_VERSION, '4.0.2', '<') ? $icon['image_path'] : $icon['relative_path']; $width = $params['width']; $height = $params['height']; // To avoid making box if (isset($params['keep_proportions'])) { if ($icon['image_x'] > $icon['image_y']) { $height = 0; } else { $width = 0; } } $icon['url'] = fn_generate_thumbnail($path, $width, $height); $real_path = $icon['absolute_path']; $size = fn_get_image_size($real_path); $icon['image_y'] = $size ? $size[0] : $params['height']; $icon['image_x'] = $size ? $size[1] : $params['width']; } else { $icon['url'] = $icon['image_path']; } if (!empty($params['use_bin_data'])) { $icon = self::getApiImageBinData($icon, $params, $type); } // Delete unnecessary fields if (isset($icon['absolute_path'])) { unset($icon['absolute_path']); } return $icon; }
/** * Check detiled image sizes ration * * @param array $image_data Image data * @param array $images Array with initial images * @param $image_width Result image width * @param $image_height Result image height * @return boolean Always true */ function fn_image_zoom_image_to_display_post(&$image_data, &$images, &$image_width, &$image_height) { if (!empty($images['detailed']) && !empty($image_data['detailed_image_path'])) { // Regenerate detailed images only if we generate product thumbnails (compare by size - it's dirty, yes) if (!in_array($image_width, array(Registry::get('settings.Thumbnails.product_details_thumbnail_width'), Registry::get('settings.Thumbnails.product_quick_view_thumbnail_width')))) { return true; } $precision = 100; $ratio_detailed = round($images['detailed']['image_x'] / $images['detailed']['image_y'] * $precision) / $precision; $ratio_original = round($image_data['width'] / $image_data['height'] * $precision) / $precision; if ($ratio_detailed != $ratio_original) { if ($ratio_detailed < $ratio_original) { $new_x = ceil($images['detailed']['image_y'] / $image_data['height'] * $image_data['width']); $new_y = $images['detailed']['image_y']; } else { $new_y = ceil($images['detailed']['image_x'] / $image_data['width'] * $image_data['height']); $new_x = $images['detailed']['image_x']; } $image_data['detailed_image_path'] = fn_generate_thumbnail($images['detailed']['relative_path'], $new_x, $new_y, false); } } return true; }
function fn_image_to_display($images, $image_width = 0, $image_height = 0) { if (empty($images)) { return array(); } $image_data = array(); // image pair passed if (!empty($images['icon']) || !empty($images['detailed'])) { if (!empty($images['icon'])) { $original_width = $images['icon']['image_x']; $original_height = $images['icon']['image_y']; $image_path = $images['icon']['image_path']; $absolute_path = $images['icon']['absolute_path']; $relative_path = $images['icon']['relative_path']; } else { $original_width = $images['detailed']['image_x']; $original_height = $images['detailed']['image_y']; $image_path = $images['detailed']['image_path']; $absolute_path = $images['detailed']['absolute_path']; $relative_path = $images['detailed']['relative_path']; } $detailed_image_path = !empty($images['detailed']['image_path']) ? $images['detailed']['image_path'] : ''; $alt = !empty($images['icon']['alt']) ? $images['icon']['alt'] : $images['detailed']['alt']; // single image passed only } else { $original_width = $images['image_x']; $original_height = $images['image_y']; $image_path = $images['image_path']; $alt = $images['alt']; $detailed_image_path = ''; $absolute_path = $images['absolute_path']; $relative_path = $images['relative_path']; } if (!empty($image_height) && empty($image_width) && !empty($original_height)) { $image_width = intval($image_height * $original_width / $original_height); } if (!empty($image_width) && empty($image_height) && !empty($original_width)) { $image_height = intval($image_width * $original_height / $original_width); } if (!empty($image_width) && !empty($relative_path) && !empty($absolute_path)) { $image_path = fn_generate_thumbnail($relative_path, $image_width, $image_height, Registry::get('config.tweaks.lazy_thumbnails')); } else { $image_width = $original_width; $image_height = $original_height; } if (!empty($image_path)) { $image_data = array('image_path' => $image_path, 'detailed_image_path' => $detailed_image_path, 'alt' => $alt, 'width' => $image_width, 'height' => $image_height, 'absolute_path' => $absolute_path, 'generate_image' => strpos($image_path, '&image_path=') !== false); } /** * Additionally processes image data * * @param array $image_data Image data * @param array $images Array with initial images * @param $image_width Result image width * @param $image_height Result image height */ fn_set_hook('image_to_display_post', $image_data, $images, $image_width, $image_height); return $image_data; }
protected function getImageUrl($image_pair) { $url = ''; if ($this->options['image_type'] == 'detailed') { $url = $image_pair['detailed']['image_path']; } else { $image_data = fn_image_to_display($image_pair, $this->options['thumbnail_width'], $this->options['thumbnail_height']); if (!empty($image_data) && strpos($image_data['image_path'], '.php')) { $image_data['image_path'] = fn_generate_thumbnail($image_data['detailed_image_path'], $image_data['width'], $image_data['height']); } if (!empty($image_data['image_path'])) { $url = $image_data['image_path']; } } $url = htmlspecialchars($url, ENT_QUOTES, 'UTF-8'); $url = fn_yandex_market_c_encode($url); $url = fn_query_remove($url, 't'); return str_replace('–', urlencode('–'), $url); }
$image_path = 'sess_data/' . fn_basename($_REQUEST['image']); if (Storage::instance('custom_files')->isExist($image_path)) { $real_path = Storage::instance('custom_files')->getAbsolutePath($image_path); list(, , $image_type, $tmp_path) = fn_get_image_size($real_path); if ($type == 'T') { $thumb_path = $image_path . '_thumb'; if (!Storage::instance('custom_files')->isExist($thumb_path)) { // Output a thumbnail image list($cont, $format) = fn_resize_image($tmp_path, Registry::get('settings.Thumbnails.product_lists_thumbnail_width'), Registry::get('settings.Thumbnails.product_lists_thumbnail_height'), Registry::get('settings.Thumbnails.thumbnail_background_color')); if (!empty($cont)) { Storage::instance('custom_files')->put($thumb_path, array('contents' => $cont)); } } $real_path = Storage::instance('custom_files')->getAbsolutePath($thumb_path); } header('Content-type: ' . $image_type); fn_echo(fn_get_contents($real_path)); exit; } // Not image file. Display spacer instead. header('Content-type: image/gif'); readfile(fn_get_theme_path('[themes]/[theme]') . '/media/images/spacer.gif'); exit; } elseif ($mode == 'thumbnail') { $img = fn_generate_thumbnail($_REQUEST['image_path'], $_REQUEST['w'], $_REQUEST['h']); if (!empty($img)) { header('Content-type: ' . fn_get_file_type($img)); fn_echo(fn_get_contents($img)); } exit; }
function fn_exim_mailru_get_image_url($product_id, $object_type, $pair_type, $get_icon, $get_detailed, $lang_code) { $image_pair = fn_get_image_pairs($product_id, $object_type, $pair_type, $get_icon, $get_detailed, $lang_code); $image_data = fn_image_to_display($image_pair, Registry::get('settings.Thumbnails.product_details_thumbnail_width'), Registry::get('settings.Thumbnails.product_details_thumbnail_height')); if (strpos($image_data['image_path'], '.php')) { $image_data['image_path'] = fn_generate_thumbnail($image_data['detailed_image_path'], $image_data['width'], $image_data['height']); } if (!empty($image_data['image_path'])) { $url = $image_data['image_path']; } else { $url = ''; } return htmlspecialchars($url, ENT_QUOTES, 'UTF-8'); }
function fn_find_valid_image_path($image_pair, $object_type, $get_flash, $lang_code) { if (isset($image_pair['icon']['absolute_path']) && is_file($image_pair['icon']['absolute_path'])) { if (!$get_flash && isset($image_pair['icon']['is_flash']) && $image_pair['icon']['is_flash']) { // We don't need Flash at all -- no need to crawl images any more. return false; } else { return $image_pair['icon']['image_path']; } } // Try to get the product's image. if (!empty($image_pair['image_id'])) { $image = fn_get_image($image_pair['image_id'], $object_type, 0, $lang_code); if (isset($image['absolute_path']) && is_file($image['absolute_path'])) { if (!$get_flash && isset($image['is_flash']) && $image['is_flash']) { return false; } return $image['image_path']; } } // If everything above failed, try to generate the thumbnail. if (!empty($image_pair['detailed_id'])) { $image = fn_get_image($image_pair['detailed_id'], 'detailed', 0, $lang_code); if (isset($image['absolute_path']) && is_file($image['absolute_path'])) { if (isset($image['is_flash']) && $image['is_flash']) { if ($get_flash) { // No need to call fn_generate_thumbnail() return $image['image_path']; } else { return false; } } $image = fn_generate_thumbnail($image['image_path'], Registry::get('settings.Thumbnails.product_details_thumbnail_width'), Registry::get('settings.Thumbnails.product_details_thumbnail_height'), false); if (!empty($image)) { return $image; } } } return false; }
protected function getImageUrl($image_pair) { $url = ''; if (empty($image_pair)) { return ''; } if ($this->options['image_type'] == 'detailed') { if (!empty($image_pair['detailed'])) { $url = $image_pair['detailed']['image_path']; } } else { $image_data = fn_image_to_display($image_pair, $this->options['thumbnail_width'], $this->options['thumbnail_height']); if (!empty($image_data) && strpos($image_data['image_path'], '.php')) { $image_data['image_path'] = fn_generate_thumbnail($image_data['detailed_image_path'], $image_data['width'], $image_data['height']); } if (!empty($image_data['image_path'])) { $url = $image_data['image_path']; } } $url = $this->escapeUrl($url); $url = fn_query_remove($url, 't'); return str_replace('–', urlencode('–'), $url); }
function ls_minicart_generate_markup($ls_cart_product, $hash) { $base_url = fn_ls_get_base_url(); //get thumbnail path // $image_relative_path = fn_get_image_pairs($ls_cart_product['product_id'], 'product', 'M', true, true, CART_LANGUAGE); // $image_relative_path=$image_relative_path['detailed']['relative_path']; $image_relative_path = fn_get_cart_product_icon($ls_cart_product['product_id'], $ls_cart_product, true); $image_relative_path = $image_relative_path['detailed']['relative_path']; $thumbnail_path = fn_generate_thumbnail($image_relative_path, 120, null, false); if (!empty($thumbnail_path)) { $ls_product_image = "<img class='ty-pict' src='{$thumbnail_path}'>"; } else { $ls_product_image = "<span class='ty-no-image' style='min-width: 120px; min-height: 168px;'><i class='ty-no-image__icon ty-icon-image'></i></span>"; } //format price $ls_product_price = $ls_cart_product['price']; $ls_product_price = fn_format_price_by_currency($ls_product_price); //generate product options $ls_cart_options = ""; foreach ($ls_cart_product['ls_minicart_options'] as $k => $option) { if ($_SESSION['settings']['cart_languageC']['value'] === 'en') { if (isset($option[0]['variant_name'])) { $ls_cart_options = $ls_cart_options . "<span class='ty-product-options clearfix'>\n <span class='ty-product-options-name ls_minicart_option_name'>{$option[0]['option_name']}: </span>\n <span class='ty-product-options-content ls_minicart_variant_name'>{$option[0]['variant_name']} </span>\n </span>"; } } else { if (isset($option[1]['variant_name'])) { $ls_cart_options = $ls_cart_options . "<span class='ty-product-options clearfix'>\n <span class='ty-product-options-name ls_minicart_option_name'>{$option[1]['option_name']}: </span>\n <span class='ty-product-options-content ls_minicart_variant_name'>{$option[1]['variant_name']} </span>\n </span>"; } } } //generate product options //$ls_move_form_options="<span class='ls_move_to_wishlist'>add_to_wishlist</span>"; $ls_move_form_options = "<input type='hidden' name='product_data[{$ls_cart_product['product_id']}][product_id]' value='{$ls_cart_product['product_id']}'>"; $ls_move_form_options .= "<input type='hidden' name='ls_move_to' value='wishlist'>"; $ls_move_form_options .= "<input type='hidden' name='ls_cart_combination_hash' value='{$hash}'>"; foreach ($ls_cart_product['product_options'] as $option_id => $option) { $ls_move_form_options .= "<input type='hidden' name='product_data[{$ls_cart_product['product_id']}][product_options][{$option_id}]' value='{$option}'>"; } $ls_move_form_options .= "<span class='ls_move_to_wishlist'>add_to_wishlist</span>"; //return the html if (!empty($ls_cart_product['product_options'])) { $markup = "<li class='ty-cart-items__list-item'>\n <span style='display: none' class='ls_cart_combination_hash'>{$hash}</span>\n <span style='display: none' class='ls_cart_combination_id'>{$ls_cart_product['product_id']}</span>\n <div class='ty-cart-items__list-item-desc'>\n <a href='{$base_url}/?dispatch=products.view?product_id={$ls_cart_product['product_id']}&wishlist_id={$hash}'>{$ls_cart_product['product']}</a>\n <p>\n <span class='ls_cart_product_amount'>{$ls_cart_product['amount']}</span><span> x </span><span>{$ls_product_price}</span>\n </p>\n <div class='row-fluid'>\n <span class='span4'>\n <div class='ty-cart-items__list-item-image ls_cart_product_image'>\n {$ls_product_image}\n </div>\n </span>\n <form class='ls_move_to_wishlist_form'>\n {$ls_move_form_options}\n </form>\n <!--div class='ls_cart_options'-->\n <span class='span8'>\n <div class='ty-control-group ty-product-options__info clearfix'>\n <!--div class='ls_cart_options_title'--><label class='ty-product-options__title'>Optiuni:</label><!--/div--> \n {$ls_cart_options}\n </div>\n </span>\n <!--/div-->\n <div/>\n </div>\n <div class='ty-cart-items__list-item-tools cm-cart-item-delete'>\n <a data-ca-dispatch='delete_cart_item' href='{$base_url}/index.php?dispatch=checkout.delete.from_status&cart_id={$hash}' class='cm-ajax ls_delete_icon' data-ca-target-id='cart_status*'><i title='Ştergeţi' class='ty-icon-cancel-circle'></i></a>\n </div>\n </li>"; } else { $markup = "<li class='ty-cart-items__list-item'>\n <span style='display: none' class='ls_cart_combination_hash'>{$hash}</span>\n <span style='display: none' class='ls_cart_combination_id'>{$ls_cart_product['product_id']}</span>\n <div class='ty-cart-items__list-item-desc'>\n <a href='{$base_url}/?dispatch=products.view?product_id={$ls_cart_product['product_id']}&wishlist_id={$hash}'>{$ls_cart_product['product']}</a>\n <p>\n <span class='ls_cart_product_amount'>{$ls_cart_product['amount']}</span><span> x </span><span>{$ls_product_price}</span>\n </p>\n <div class='row-fluid'>\n <span class='span4'>\n <div class='ty-cart-items__list-item-image'>\n {$ls_product_image}\n </div>\n </span>\n <form class='ls_move_to_wishlist_form'>\n {$ls_move_form_options}\n </form>\n <span class='span8'>\n <!--div class='ls_cart_options'-->\n <div class='ty-control-group ty-product-options__info clearfix'>\n </div>\n <!--/div-->\n </span> \n </div>\n </div>\n <div class='ty-cart-items__list-item-tools cm-cart-item-delete'>\n <a data-ca-dispatch='delete_cart_item' href='{$base_url}/index.php?dispatch=checkout.delete.from_status&cart_id={$hash}' class='cm-ajax ls_delete_icon' data-ca-target-id='cart_status*'><i title='Ştergeţi' class='ty-icon-cancel-circle'></i></a>\n </div>\n </li>"; } return $markup; }
} else { // echo 'bad request'; } exit; } elseif ($mode == 'ls_generate_wishlist_markup') { $base_url = fn_ls_get_base_url(); //changed parameters correction $_REQUEST['ls_productId'] = reset(array_keys($_REQUEST['product_data'])); $_REQUEST['current_url'] = $_REQUEST["redirect_url"]; $_REQUEST['ls_cart_combination_hash'] = $_REQUEST['ls_product_combination_hash']; //get thumbnail path // $image_relative_path = fn_get_image_pairs($_REQUEST['ls_productId'], 'product', 'M', true, true, CART_LANGUAGE); // $image_relative_path=$image_relative_path['detailed']['relative_path']; $image_relative_path = fn_get_cart_product_icon($_REQUEST['ls_productId'], $_REQUEST['product_data'][$_REQUEST['ls_productId']], true); $image_relative_path = $image_relative_path['detailed']['relative_path']; $thumbnail_path = fn_generate_thumbnail($image_relative_path, 150, 150, false); if (!empty($thumbnail_path)) { $fav_product_img = "<img class='ty-pict' src='{$thumbnail_path}'>"; } else { $fav_product_img = "<span class='ty-no-image' style='min-width: 118px; min-height: 150px;'><i class='ty-no-image__icon ty-icon-image'></i></span>"; } $wishlist =& $_SESSION['wishlist']; $found = array(); //get the required id hash from session based on product_id foreach ($wishlist as $k0 => $v0) { foreach ($v0 as $k1 => $v1) { if (multi_array_search($_REQUEST['ls_productId'], $v1)) { $footerFavId2 = $k1; $product_options = $v1['product_options']; } }