ionic-image-loader icon indicating copy to clipboard operation
ionic-image-loader copied to clipboard

[Feature request] Ability to make this work with ionic-img-viewer

Open Shane-Lester opened this issue 7 years ago • 5 comments

I've unsuccessfully combining this with ionic-img-viewer. Is there any way to enable pinch/zoom functionality when combined with ionic-image-loader's caching.

Shane-Lester avatar Jul 26 '17 13:07 Shane-Lester

I tried to make this work before in #17 with no luck. I can review that module again and see what I can do. I might be able to create a combined component.

ihadeed avatar Sep 02 '17 03:09 ihadeed

I've been using the 2 plugins via sth like..

    <img-loader
        imageViewer="{{getLocalPath(urlToImage)}}" (load)="cacheLocalPath($event)" 
        [src]="urlToImage">
    </img-loader>

cacheLocalPath() can be used to cache the local path in a url->local_path hash.

baskin avatar Sep 04 '17 11:09 baskin

Can you give me a bit more info. I'm currently using this format in my html <img-loader [src]="picture" useImg></img-loader> where picture is a firebase.storage URL stored in a JSON object which is iterated through in my html.

I'm assuming that the load event will fire when this is loaded by the img-loader element. What do I do with the $event. I can log it and see that it is of type ImgLoader. Do I create an object with the url (picture) as a key? I've tried passing picture to a function called getLocalPath. Should this then go ahead and look something up?

Thanks for any help you can give me

Shane-Lester avatar Sep 17 '17 15:09 Shane-Lester

I've tried what @baskin suggested, however I receive a 'Can't bind to 'imageViewer' since it isn't a known property of 'img-loader' error.

Any ideas on how to use these two in tandem?

jaybloke avatar Jun 05 '18 00:06 jaybloke

I've solved handling both of the plugins like this:

My picture object contains all the data, related to the picture like the source url, picture name, etc..

Markup <img-loader src="{{ picture.pictureUrl }}" #imageViewerPicture (click)="this.showPicture($event.target, picture.pictureUrl);"></img-loader>

Function

	protected showPicture(picture: any, pictureData: any): void {

		/** create a new image viewer for the selected picture */
		const imageViewer: ImageViewer = this.imageViewerCtrl.create(picture);

		/** on image viewer present */
		imageViewer.present().then(() => {

			/** do something else here like tracking */
			return;
		});

		/** on image viewer dismiss */
		imageViewer.onDidDismiss(() => {

			/** do something else here like tracking */
			return;
		});
		return;
	}

Hope it helps someone.

Cheers Unkn0wn0x

0x426 avatar Dec 29 '18 00:12 0x426