Esempio n. 1
0
function fn_watermarks_attach_absolute_image_paths(&$image_data, &$object_type, &$path, &$image_name)
{
    if (!empty($image_data['image_path'])) {
        $is_detailed = $object_type == 'detailed' ? true : false;
        $company_id = null;
        if (empty($image_data['object_type'])) {
            $image_data['object_type'] = $object_type;
        }
        $prefix = WATERMARKS_DIR_NAME;
        if (fn_allowed_for('ULTIMATE') && !Registry::get('runtime.company_id')) {
            $company_id = fn_wt_get_image_company_id($image_data);
            $prefix = WATERMARKS_DIR_NAME . $company_id . '/';
        }
        if (fn_is_need_watermark($image_data['object_type'], $is_detailed, $company_id)) {
            $image_data['http_image_path'] = Storage::instance('images')->getUrl($prefix . $path . '/' . $image_name, 'http');
            $image_data['absolute_path'] = Storage::instance('images')->getAbsolutePath($prefix . $path . '/' . $image_name);
            $image_data['image_path'] = Storage::instance('images')->getUrl($prefix . $path . '/' . $image_name);
            if (!Storage::instance('images')->isExist($prefix . $path . '/' . $image_name)) {
                fn_watermark_create($image_data['relative_path'], $prefix . $path . '/' . $image_name, $is_detailed, $company_id);
            }
        }
    }
    return true;
}
Esempio n. 2
0
}
//
// Delete image
//
if ($mode == 'create') {
    $result_image = '';
    if (!empty($_SERVER['REQUEST_URI'])) {
        $path = defined('HTTPS') ? Registry::get('config.https_path') : Registry::get('config.http_path');
        $image_file = str_replace($path . '/images/', '', $_SERVER['REQUEST_URI']);
        $watermarked_file = WATERMARKS_DIR_NAME . $image_file;
        if (Storage::instance('images')->isExist($watermarked_file)) {
            $result_image = Storage::instance('images')->getUrl($watermarked_file);
        } elseif (Storage::instance('images')->isExist($image_file)) {
            $image_name = fn_basename($image_file);
            $image_id = db_get_field("SELECT image_id FROM ?:images WHERE image_path LIKE ?l", "%{$image_name}%");
            $image_link = db_get_row("SELECT * FROM ?:images_links WHERE image_id = ?i OR detailed_id = ?i", $image_id, $image_id);
            if (!empty($image_link)) {
                $is_detailed = $image_link['detailed_id'] == $image_id;
                $image_type = $is_detailed ? 'detailed' : 'icons';
                $generate_watermark = fn_is_need_watermark($image_link['object_type'], $is_detailed, Registry::get('runtime.company_id'));
                if (fn_watermark_create($image_file, $watermarked_file, $is_detailed, Registry::get('runtime.company_id'), $generate_watermark)) {
                    $result_image = Storage::instance('images')->getUrl($watermarked_file);
                }
            }
        }
    }
    if (!empty($result_image)) {
        header('Location: ' . $result_image);
    }
    exit;
}
Esempio n. 3
0
/**
 * Hook handler for image_zoom addon, if detail image not proportional for thumbnail
 * @param string $file_path
 * @param array $image_data
 * @param array $images
 */
function fn_watermarks_image_zoom_check_image_post(&$file_path, &$image_data, &$images)
{
    $company_id = null;
    if (fn_allowed_for('ULTIMATE')) {
        $company_id = fn_wt_get_image_company_id($images['detailed']);
    }
    if (fn_is_need_watermark('product', false, $company_id) || !fn_is_need_watermark('product', true, $company_id)) {
        return;
    }
    $data = $images['detailed'];
    $data['relative_path'] = $file_path;
    $type = 'detailed';
    $name = basename($file_path);
    $path = dirname($file_path);
    fn_watermarks_attach_absolute_image_paths($data, $type, $path, $name);
    $file_path = $data['image_path'];
}