File tree Expand file tree Collapse file tree 2 files changed +12
-7
lines changed
Expand file tree Collapse file tree 2 files changed +12
-7
lines changed Original file line number Diff line number Diff line change 5858 ".webp" : WEBP ,
5959 }
6060
61- imageFormatsBySubType = map [string ]Format {
61+ // These are the image types we can process.
62+ processableImageSubTypes = map [string ]Format {
6263 media .Builtin .JPEGType .SubType : JPEG ,
6364 media .Builtin .PNGType .SubType : PNG ,
6465 media .Builtin .TIFFType .SubType : TIFF ,
@@ -123,7 +124,7 @@ func ImageFormatFromExt(ext string) (Format, bool) {
123124}
124125
125126func ImageFormatFromMediaSubType (sub string ) (Format , bool ) {
126- f , found := imageFormatsBySubType [sub ]
127+ f , found := processableImageSubTypes [sub ]
127128 return f , found
128129}
129130
Original file line number Diff line number Diff line change @@ -402,12 +402,16 @@ func (r *resourceAdapter) getImageOps() images.ImageResourceOps {
402402
403403// IsImage reports whether the given resource is an image that can be processed.
404404func IsImage (v any ) bool {
405- r , ok := v .(* resourceAdapter )
406- if ok {
407- _ , ok := r .target .(images.ImageResourceOps )
408- return ok
405+ r , ok := v .(resource.Resource )
406+ if ! ok {
407+ return false
409408 }
410- return false
409+ mt := r .MediaType ()
410+ if mt .MainType != "image" {
411+ return false
412+ }
413+ _ , isImage := images .ImageFormatFromMediaSubType (mt .SubType )
414+ return isImage
411415}
412416
413417func (r * resourceAdapter ) publish () {
You can’t perform that action at this time.
0 commit comments