From df277e5977cb0b1f7e11c7e94265029f8e37ece4 Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Wed, 3 Jan 2024 09:53:41 -0800 Subject: Multiple improvements to link cards and quote posts (#2398) * fix canvas * fix external link embed styles * Use the same link-card style on web and mobile and give a little more height on desktop to the card images * Use dark border on link embeds to match quote post style * Fix the highlighting behavior on linkcards and quoteposts --------- Co-authored-by: Hailey --- src/lib/media/manip.web.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src/lib/media/manip.web.ts') diff --git a/src/lib/media/manip.web.ts b/src/lib/media/manip.web.ts index 914b05d2e..bdf6836a1 100644 --- a/src/lib/media/manip.web.ts +++ b/src/lib/media/manip.web.ts @@ -117,9 +117,6 @@ function createResizedImage( return reject(new Error('Failed to resize image')) } - canvas.width = width - canvas.height = height - let scale = 1 if (mode === 'cover') { scale = img.width < img.height ? width / img.width : height / img.height @@ -128,10 +125,11 @@ function createResizedImage( } let w = img.width * scale let h = img.height * scale - let x = (width - w) / 2 - let y = (height - h) / 2 - ctx.drawImage(img, x, y, w, h) + canvas.width = w + canvas.height = h + + ctx.drawImage(img, 0, 0, w, h) resolve(canvas.toDataURL('image/jpeg', quality)) }) img.src = dataUri -- cgit 1.4.1