feat(cloudinary): use Staticaly CDN

This commit is contained in:
curben 2019-08-26 06:18:09 +09:30
parent 910dde814f
commit c416aedb2d
No known key found for this signature in database
GPG Key ID: 5D9DB57A25D34EE3
2 changed files with 6 additions and 5 deletions

View File

@ -14,8 +14,9 @@ hexo.extend.tag.register('cloudinary', (args) => {
const alt = args[1] || ''
let modern = ''
let legacy = ''
const cloudinary = 'https://res.cloudinary.com/' + user +
'/image/upload/f_auto,q_auto'
const cloudinary = 'https://cdn.statically.io/img/res.cloudinary.com/' + user +
'/image/upload/q_auto'
const original = 'https://cdn.statically.io/img/res.cloudinary.com/' + user + '/' + fileName
if (fileName.endsWith('.png')) {
modern = fileName.replace(/\.png$/, '.webp')
@ -40,7 +41,7 @@ hexo.extend.tag.register('cloudinary', (args) => {
alt="${alt}">`
if (fileName.endsWith('.png') || fileName.endsWith('.webp')) {
return `<a href="https://res.cloudinary.com/curben/${fileName}">
return `<a href="${original}">
<picture>
<source type="image/webp"
srcset="${cloudinary}/c_limit,w_320/${modern} 320w,
@ -54,7 +55,7 @@ hexo.extend.tag.register('cloudinary', (args) => {
${img}
</picture></a>`
} else {
return `<a href="https://res.cloudinary.com/curben/${fileName}">
return `<a href="${original}">
${img}</a>`
}
})

View File

@ -3,7 +3,7 @@
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
Content-Language: en
Content-Security-Policy: default-src 'self'; child-src 'none'; connect-src 'none'; font-src 'none'; frame-src 'none'; img-src https: 'self'; manifest-src 'none'; media-src 'none'; object-src 'none'; prefetch-src 'none'; script-src https://cdnjs.cloudflare.com 'self'; style-src https://cdnjs.cloudflare.com 'self'; worker-src 'none'; base-uri 'none'; form-action https://duckduckgo.com; frame-ancestors 'none'; block-all-mixed-content
Content-Security-Policy: default-src 'self'; child-src 'none'; connect-src 'none'; font-src 'none'; frame-src 'none'; img-src https://cdn.statically.io 'self'; manifest-src 'none'; media-src 'none'; object-src 'none'; prefetch-src 'none'; script-src https://cdnjs.cloudflare.com 'self'; style-src https://cdnjs.cloudflare.com 'self'; worker-src 'none'; base-uri 'none'; form-action https://duckduckgo.com; frame-ancestors 'none'; block-all-mixed-content
Referrer-Policy: no-referrer
Strict-Transport-Security: max-age=31536000
Feature-Policy: accelerometer 'none'; autoplay 'none'; camera 'none'; document.domain 'none'; display-capture 'none'; encrypted-media 'none'; geolocation 'none'; gyroscope 'none'; magnetometer 'none'; microphone 'none'; midi 'none'; payment 'none'; sync-xhr 'none'; usb 'none'