Update image optimization to remote astro asset loading
This commit is contained in:
@@ -210,14 +210,14 @@ const getBreakpoints = ({
|
||||
};
|
||||
|
||||
/* ** */
|
||||
export const astroAsseetsOptimizer: ImagesOptimizer = async (image, breakpoints) => {
|
||||
if (!image || typeof image === 'string') {
|
||||
export const astroAsseetsOptimizer: ImagesOptimizer = async (image, breakpoints, width, height) => {
|
||||
if (!image) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Promise.all(
|
||||
breakpoints.map(async (w: number) => {
|
||||
const url = (await getImage({ src: image, width: w })).src;
|
||||
const url = (await getImage({ src: image, width: w, inferSize: true })).src;
|
||||
return {
|
||||
src: url,
|
||||
width: w,
|
||||
@@ -226,6 +226,10 @@ export const astroAsseetsOptimizer: ImagesOptimizer = async (image, breakpoints)
|
||||
);
|
||||
};
|
||||
|
||||
export const isUnpicCompatible = (image: string) => {
|
||||
return typeof parseUrl(image) !== 'undefined';
|
||||
};
|
||||
|
||||
/* ** */
|
||||
export const unpicOptimizer: ImagesOptimizer = async (image, breakpoints, width, height) => {
|
||||
if (!image || typeof image !== 'string') {
|
||||
|
Reference in New Issue
Block a user