From ec2de84f66ae1b76ebe3d764212811422df98dd6 Mon Sep 17 00:00:00 2001 From: curben <2809763-curben@users.noreply.gitlab.com> Date: Sun, 25 Aug 2019 19:09:26 +0930 Subject: [PATCH] fix(cloudinary): use similar resolutions in typing.css --- scripts/cloudinary.js | 69 ++++++++++++++++--------------------------- 1 file changed, 25 insertions(+), 44 deletions(-) diff --git a/scripts/cloudinary.js b/scripts/cloudinary.js index 2098938..a369816 100644 --- a/scripts/cloudinary.js +++ b/scripts/cloudinary.js @@ -15,7 +15,7 @@ hexo.extend.tag.register('cloudinary', (args) => { let modern = '' let legacy = '' const cloudinary = 'https://res.cloudinary.com/' + user + - '/image/upload/f_auto,q_auto/c_limit,' + '/image/upload/f_auto,q_auto' if (fileName.endsWith('.png')) { modern = fileName.replace(/\.png$/, '.webp') @@ -23,57 +23,38 @@ hexo.extend.tag.register('cloudinary', (args) => { } else if (fileName.endsWith('.webp')) { modern = fileName legacy = fileName.replace(/\.webp$/, '.gif') + } else { + legacy = fileName } + const img = ` + src="${cloudinary}w_768/${legacy}" + alt="${alt}">` + if (fileName.endsWith('.png') || fileName.endsWith('.webp')) { return ` - ${alt} + srcset="${cloudinary}/c_limit,w_320/${modern} 320w, + ${cloudinary}/c_limit,w_468/${modern} 468w, + ${cloudinary}/c_limit,w_768/${modern} 768w, + ${cloudinary}/${modern} 800w" + sizes="(max-width: 320px) 320px, + (max-width: 468px) 468px, + (max-width: 768px) 768px, + 800px"> + ${img} ` } else { return ` - ${alt} - ` + ${img}` } })