Skip to content

Commit

Permalink
Fixed media variants handling in media permalink resolver.
Browse files Browse the repository at this point in the history
  • Loading branch information
azaslonov committed Dec 7, 2024
1 parent 2377412 commit 640285b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/media/mediaPermalinkResolver.publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { MediaContract } from "./mediaContract";
import { ContentItemContract } from "../contentModel";
import { HyperlinkContract } from "../editing";


export class MediaPermalinkResolver implements IPermalinkResolver {
protected mediaPath: string = "uploads/";

Expand All @@ -27,7 +28,7 @@ export class MediaPermalinkResolver implements IPermalinkResolver {
return null;
}

if (media.variants) { // Currently this case is possible only with CDN and image optimization services.
if (media.variants?.length > 0) { // Currently this case is possible only with CDN and image optimization services.
const biggestVariant = MediaUtils.getBiggestMediaVariant(media);
return biggestVariant.downloadUrl;
}
Expand All @@ -36,7 +37,7 @@ export class MediaPermalinkResolver implements IPermalinkResolver {
}
}
catch (error) {
console.warn(`Could not fetch permalink by key ${mediaKey}.`);
console.warn(`Could not fetch permalink by key ${mediaKey}. Error: ${error.message}`);
return null;
}
}
Expand Down

0 comments on commit 640285b

Please sign in to comment.