Beispiel #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;
}
Beispiel #2
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'];
}