From f4457d0e1b8c852996490850e4f781fb65e74ea4 Mon Sep 17 00:00:00 2001 From: cupcakearmy Date: Sun, 20 Dec 2020 10:11:22 +0100 Subject: [PATCH] further logging and auto defaults --- src/index.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index 2385a15..aa7a102 100644 --- a/src/index.ts +++ b/src/index.ts @@ -28,7 +28,7 @@ export function initialize(cloudinary: Configuration.Options, options: InitParam const defaults: Transformation | Transformation.Options = { fetchFormat: 'auto', - quality: 'auto:good', + quality: 'auto', } function calculateApproxRealSize(size: string, step: number): number { @@ -64,8 +64,9 @@ export function image(node: HTMLImageElement, parameters: ImageParameters) { let { src, options, bind, lazy, step } = parameters log('Image Declared', parameters) - options = options || {} + options = options ?? {} step = step ?? 200 + lazy = lazy ?? true if (!cl) throw new Error('Cloudinary not initialized') if (!src) throw new Error('Src must be set in use:image') @@ -91,6 +92,7 @@ export function image(node: HTMLImageElement, parameters: ImageParameters) { const all: Transformation | Transformation.Options = { ...defaults, ...options } const attrs: any = cl.imageTag(parameters.src, all).attributes() + log('Attributes', attrs) const replace = () => (node.src = attrs.src) if (lazy && typeof IntersectionObserver !== 'undefined') {