nativescript-community / ui-image

Advanced and efficient image display plugin which uses Fresco (Android) and SDWebImage (iOS) to implement caching, placeholders, image effects, and much more.
Apache License 2.0
36 stars 9 forks source link

Placeholder image on Android is not scaled with stretch property #22

Closed yvdv-one closed 8 months ago

yvdv-one commented 4 years ago

Which platform(s) does your issue occur on?

Please, provide the following version numbers that your issue occurs with:

Please, tell us how to recreate the issue in as much detail as possible.

<NSImg src="{{...}}" placeholderImageUri="{{..}}" stretch="aspectFit" width="100%"
           verticalAlignment="top"></NSImg>

The placeholder image is shown smaller than the actual image. Looking at the code, it seems that the stretch property is not used in setting the placeholder image on the fresco GenericDraweeHierarchyBuilder, resulting in the default scale CENTER_INSIDE.

yvdv-one commented 4 years ago

The issue would be fixed with the following code changes in image.android.ts:

if (this.placeholderImageUri && placeholderImageDrawable) { builder.setPlaceholderImage(placeholderImageDrawable, this.stretch); }

and lines 771-778:

public setPlaceholderImage(drawable, scaleType: string): GenericDraweeHierarchyBuilder { if (!this.nativeBuilder) { return this; } if (scaleType) { this.nativeBuilder.setPlaceholderImage(drawable, getScaleType(scaleType)); } else { this.nativeBuilder.setPlaceholderImage(drawable); } return this; }

I could not create a branch to submit the code, unfortunately.

farfromrefug commented 4 years ago

@yvdv-one sorry don't really have much free time those day. Can you create a PR? Thanks

yvdv-one commented 4 years ago

@farfromrefug Thank you for responding. I created a fork, made the changes and created a PR. 

Yves.

farfromrefug commented 4 years ago

@yvdv-one thanks a lot! released under 3.0.1