@usequeek/theme-kit 0.5.5 → 0.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/utils/image-srcset.ts +10 -3
package/package.json
CHANGED
package/utils/image-srcset.ts
CHANGED
|
@@ -201,12 +201,19 @@ export function resolveImageSources(
|
|
|
201
201
|
* (a 2048 px JPG of 139 KB is a 38 KB WebP). Never a smaller tier: a wide wordmark
|
|
202
202
|
* on a 3x phone would come out softer than the upload it replaces. The raw `url`
|
|
203
203
|
* when there is no `view` copy, no copies at all (an SVG, an off-host file) or
|
|
204
|
-
* copies of a different file
|
|
204
|
+
* copies of a different file, and when the upload is already a WebP no wider than
|
|
205
|
+
* `view`: the copy is then the same picture re-encoded, and often heavier (an 8 KB
|
|
206
|
+
* wordmark's `view` is 9.6 KB).
|
|
205
207
|
*/
|
|
206
208
|
export function logoSrc(url: string | null | undefined, variants: ImageVariants | null | undefined): string | null {
|
|
207
209
|
if (!url) {
|
|
208
210
|
return null;
|
|
209
211
|
}
|
|
210
|
-
const
|
|
211
|
-
|
|
212
|
+
const original = variants?.original;
|
|
213
|
+
const view = variants && original?.url === url ? variants.view : null;
|
|
214
|
+
if (!usableTier(view)) {
|
|
215
|
+
return url;
|
|
216
|
+
}
|
|
217
|
+
const samePixels = typeof view.w === 'number' && typeof original?.w === 'number' && view.w >= original.w;
|
|
218
|
+
return samePixels && /\.webp(?:[?#]|$)/i.test(url) ? url : view.url;
|
|
212
219
|
}
|