File tree Expand file tree Collapse file tree
packages/issuance-branding/src/agent Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -341,12 +341,18 @@ export class IssuanceBranding implements IAgentPlugin {
341341
342342 debug ( 'Setting additional image properties for url' , image . uri )
343343 const resource : IImageResource | undefined = ! image . dataUri ? await downloadImage ( image . uri ) : undefined
344- const dimensions : IImageDimensions =
345- image . dimensions ?? ( await getImageDimensions ( resource ?. base64Content ?? ( await this . extractBase64FromDataURI ( image . dataUri ! ) ) ) )
344+
345+ if ( ! resource ?. base64Content && ! image . dataUri ) {
346+ debug ( `Could not download image from ${ image . uri } and no dataUri available, returning empty attributes` )
347+ return EMPTY_IMAGE_ATTRIBUTES
348+ }
349+
350+ const base64Content : string = resource ?. base64Content ?? ( await this . extractBase64FromDataURI ( image . dataUri ! ) )
351+ const dimensions : IImageDimensions = image . dimensions ?? ( await getImageDimensions ( base64Content ) )
346352 const mediaType : string | undefined =
347353 image . mediaType ??
348354 resource ?. contentType ??
349- ( resource ?. base64Content ? await getImageMediaType ( resource ? .base64Content ! ) : await this . getDataTypeFromDataURI ( image . uri ) )
355+ ( resource ?. base64Content ? await getImageMediaType ( resource . base64Content ) : await this . getDataTypeFromDataURI ( image . uri ) )
350356
351357 return {
352358 mediaType,
You can’t perform that action at this time.
0 commit comments