Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@restrella/capacitor-photoviewer

balance3840162MIT7.0.1TypeScript support: included

PhotoViewer table images with fullscreen and sharing capabilities

capacitor, plugin, native, photoviewer

readme


PHOTO VIEWER

@capacitor-community/photoviewer


Capacitor community plugin for Web and Native Photo Viewer allowing to open fullscreen

- a selected picture from a grid of pictures with zoom-in and sharing features.

- a single picture with zoom-in and sharing features.

A picture can be acessed by image web url, base64 data or from internal device for iOS and Android.

- iOS

  • file:///var/mobile/Media/DCIM/100APPLE/YOUR_IMAGE.JPG
  • capacitor://localhost/_capacitor_file_/var/mobile/Containers/Data/Application/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/Documents/photo1.jpg

- Android

  • file:///sdcard/DCIM/YOUR_IMAGE.JPG
  • file:///sdcard/Pictures/YOUR_IMAGE.JPG
  • http://localhost/_capacitor_file_/storage/emulated/0/Pictures/JPEG_20221001_113835_7582877022250987909.jpg

On iOS plugin, the creation of a movie from the pictures stored in the All Photos folder is now available.




Maintainers

Maintainer GitHub Social
Robin Genz robingenz @robin_genz

Browser Support

The plugin follows the guidelines from the Capacitor Team,

meaning that it will not work in IE11 without additional JavaScript transformations, e.g. with Babel.

Installation

npm install @capacitor-community/photoviewer
npx cap sync

Since version 3.0.4, modify the capacitor.config.ts to add the image location to save the image downloaded from an HTTP request to the internal disk.

const config: CapacitorConfig = {
  ...
  plugins: {
    PhotoViewer: {
      iosImageLocation: 'Library/Images',
      androidImageLocation: 'Files/Images',
    }
  }
  ...
};

export default config;

iOS

  • in Xcode, open Info.plist and add a new Information Property like Privacy - Photo Library Usage Description and set a value to We need to write photos. This is required to have the Shareof images and the create Movie working.

Android

  • on the res project folder open the file_paths.xml file and add
    <files-path name="files" path="."/>
  • open the build.gradle (Project:android) and make sure that kotlin is declared
...
buildscript {
    ext.kotlin_version = '1.9.25'
    dependencies {
        ...
        classpath 'com.android.tools.build:gradle:8.8.1'
        classpath 'com.google.gms:google-services:4.4.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}
...
  • open the build.gradle (Module: android.app) and do the following

    • after apply plugin: 'com.android.application' add

        apply plugin: 'kotlin-android'
        apply plugin: 'kotlin-kapt'
    • in the android block add

        buildFeatures {
            dataBinding = true
        }
    • in the repositories block add

        maven { url 'https://jitpack.io' }
    • in the dependencies block add
        implementation "androidx.core:core-ktx:1.15.0"
        implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
  • Now run Sync Project with Gradle Files and you are ready.

Web, PWA

The plugin works with the companion Stencil component jeep-photoviewer. It is mandatory to install it

npm install --save-dev jeep-photoviewer@latest

Build your App

When your app is ready

npm run build
npx cap copy
npx cap copy web
npx cap open android   // Android
npx cap open ios       // iOS
npm run serve          // Web

Supported methods

Name Android iOS Electron Web
echo
show
saveImageFromHttpToInternal
getInternalImagePaths

Documentation

API_Documentation

Applications demonstrating the use of the plugin

Ionic/Angular

Ionic/Vue

React

Usage

iOS and Android

  • In Gallery mode (Image Array with more than one Image):
    • make a tap will select the image and go fullscreen
    • In Fulscreen
      • tap will hide the share and exit buttons and open the window for other gestures.
      • double tap to zoom in and out
      • pinch with your two fingers
      • tap will show the share and exit buttons and leave the window for other gestures.
      • double tap will hide the buttons and zoom in straightforward (iOS only)
  • In One Image mode (Image Array with one Image only):
    • pinch-zoom and pan with your two fingers
    • double-tap to zoom directly to the maximum zoom
  • You can pass customHeaders in the options object to let the plugin pass those headers to the http request for the image. For example:
PhotoViewer.show({
  images: [
    {
      url: 'https://picsum.photos/id/237/200/300',
      title: 'Title'
    },
    {
      url: 'https://picsum.photos/id/238/200/300',
      title: 'Title'
    },
  ],
  options: {
    customHeaders: {
      accept: 'image/jpeg, image/png, image/gif, image/webp, image/svg+xml, image/*;q=0.8, */*;q=0.5',
      cookie: 'session=foo;',
    },
  },
  mode: 'slider'
})

Dependencies

The Android code is using MikeOrtiz/TouchImageView allowing for the zooming in picture (https://github.com/MikeOrtiz/TouchImageView)

The iOS code is using SDWebImage for http async image downloader (https://github.com/SDWebImage/SDWebImage) and ISVImageScrollView for the pinch-zoom and pan in picture (https://github.com/yuriiik/ISVImageScrollView)

Contributors ✨

Thanks goes to these wonderful people (emoji key):

This project follows the all-contributors specification. Contributions of any kind welcome!

changelog

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

7.0.0 (2025-03-14)

⚠ BREAKING CHANGES

  • This plugin now only supports Capacitor 7.

Features

4.0.1 (2024-09-04)

Bug Fixes

4.0.0 (2024-08-31)

⚠ BREAKING CHANGES

  • This plugin now only supports Capacitor 6.

Features

3.2.0 (2024-05-20)

Cease of Maintenance

  • Update README.md

Chore

  • Update to @capacitor/core 5.7.5
  • Update to @capacitor/ios 5.7.5
  • Update to @capacitor/android 5.7.5

Added Features

  • Feat/custom headers PR#60 by Shiva Prasad

3.0.6 (2023_12_21)

Chore

  • Update to @capacitor/core 5.3.0
  • Update to @capacitor/ios 5.3.0
  • Update to @capacitor/android 5.3.0

3.0.5 (2023-12-21)

Bug fixes

  • Android Close button stops working after device is rotated issue#50
  • Android Display timeout disabled with plugin installed issue#43
  • iOS Photo and close button partially disappear off of screen when device is rotated issue#57 (PR#58 from camilocalvo)

3.0.4 (2023-09-24)

Added Features

  • iOS Add method saveImageFromHttpToInternal
  • iOS Add method getInternalImagePaths
  • Add iOSImageLocation definition in capacitor.config.ts

Bug fixes

  • Android fix App crashing when calling PhotoViewer.show after updating to version 3.0 and capacitor 5 issue#51

3.0.3 (2023-09-17)

Bug fixes

  • Android fix closing with transition issue#38
  • Android fix App in prod calls ANR when user exits from image viewer issue#48
  • Android fix Image title on Android issue#39
  • Android fix Close button stops working after device is rotated issue#50

3.0.2 (2023-09-16)

Bug fixes

  • Fix Web listener jeepCapPhotoViewerExitnot fired.

3.0.1 (2023-09-12)

Chore

  • Update to @capacitor/core 5.3.0
  • Update to @capacitor/ios 5.3.0
  • Update to @capacitor/android 5.3.0

Bug fixes

  • Fix request READ_MEDIA_IMAGES permission for Android SDK >= 33 PR#46 from Chirag Anand
  • Fix Kotlin Version for Capacitor in README.md PR#47 from Chirag Anand

3.0.0 (2023-05-22)

3.0.0-beta.1 (2023-05-21)

Bug fixes

  • Fix OS Share & Close button not visible issue#42
  • Fix iOS invisible close button when opens images list in a slider mode issue#36

3.0.0-beta.0 (2023-05-16)

Chore

  • Update to @capacitor/core 5.0.3
  • Update to @capacitor/ios 5.0.3
  • Update to @capacitor/android 5.0.3

2.1.0 (2023-05-21)

Chore

  • Update to @capacitor/core 4.8.0
  • Update to @capacitor/ios 4.8.0
  • Update to @capacitor/android 4.8.0

Bug fixes

  • Fix OS Share & Close button not visible issue#42
  • Fix iOS invisible close button when opens images list in a slider mode issue#36

2.0.10 (2023-01-26)

Bug fixes

  • Android change onTouch() method signature #32 (PR from Nils Braune)

2.0.9 (2023-01-18)

Chore

  • Update to @capacitor/core 4.6.1
  • Update to @capacitor/ios 4.6.1
  • Update to @capacitor/android 4.6.1

Bug fixes

  • Change method signature in OnSwipeTouchListener.kt #31 (PR from Nils Braune)

2.0.8 (2022-12-06)

Bug fixes

  • fix the web swipe-up & swipe-down gesture in jeep-photoviewer

2.0.7 (2022-12-05)

Added Features

  • Add swipe-up & swipe-down gesture issue#26

2.0.6 (2022-12-03)

Chore

  • Update to @capacitor/core 4.5.0
  • Update to @capacitor/ios 4.5.0
  • Update to @capacitor/android 4.5.0

Bug fixes

  • fix The close button is not visible in iOS with Light theme on issue#27

2.0.5 (2022-10-04)

Bug fixes

  • fix bug in Android permissions

2.0.4 (2022-10-04)

Bug fixes

  • fix issue #22 and issue #24

2.0.3 (2022-09-29)

Bug fixes

  • fix local image web path (iOS)

2.0.2 (2022-09-29)

Chore

  • Update to @capacitor/core 4.2.0
  • Update to @capacitor/ios 4.2.0
  • Update to @capacitor/android 4.2.0

Added Features

  • Add local image web path (iOS, Android) issue#22

2.0.1 (2022-09-28)

  • publish as latest release in npm

2.0.0-0 (2022-09-05)

Chore

  • Update to @capacitor/core 4.0.1
  • Update to @capacitor/ios 4.0.1
  • Update to @capacitor/android 4.0.1

1.1.3 (2022-03-09)

Bug fixes

  • 1.1.2 was taken from a wrong 1.1.1

1.1.2 (2022-03-09)

Chore

Bug fixes

  • Unable to show the SliderViewController issue#14
  • Google Play crash console issue#15

1.1.1 (2022-02-05)

Chore

Bug fixes

  • Hide placeholder when black PNG image with transparency in gallery mode Web

1.1.0 (2022-02-04)

Chore

Added Features

  • Add backgroundcolor option for iOS, Android & Web

1.0.9 (2022-01-22)

Bug fixes

  • Fix indexImage in SliderViewController iOS
  • Fix documentation Ionic-Angular-Usage.md && Ionic-Vue-Usage.md

1.0.8 (2022-01-19)

Added Features

  • Add Slider mode for iOS, Android & Web
  • Add jeepCapPhotoViewerExit plugin event listener

Bug fixes

  • Add an option to open slider directly issue#11

1.0.7 (2022-01-11)

1.0.6 (2022-01-09)

Bug fixes

  • Fix Android Image share

1.0.5 (2022-01-05)

Added Features

  • Android add back press button on the three main fragments
  • iOS add close button in the photo gallery page
  • Link to a Vite React application

Bug fixes

  • Update Readme for Android project issue#9
  • Add a link to a Vite React application issue#10

1.0.4 (2021-12-23)

Added Features

  • Fix Android Manually close the image on back pressed issue#8

1.0.3 (2021-12-15)

Chore

Bug fixes

  • Fix iOS Wrong image ratio / Image cut off issue#7

1.0.2 (2021-11-04)

Bug fixes

  • Fix issue#4

1.0.1 (2021-10-17)

Bug fixes

  • Add s.dependency 'ISVImageScrollView' to the CapacitorCommunityPhotoviewer.podspec

1.0.0 (2021-10-17)

Chore

Add Features (iOS, Android)

  • One image mode pinch-zoom and pan

Bug fixes

  • Fix issue#2

0.0.5 (2021-09-21)

Bug fixes

  • fix all issues listed in issue#2 for iOS only

0.0.4 (2021-09-20)

Add Features (Android)

  • Display a fullscreen view when the image list contains one image

0.0.3 (2021-09-19)

Chore

Add Features (Web, iOS)

  • Display a fullscreen view when the image list contains one image

0.0.2 (2021-08-12)

Chore

Add Features

  • Add Ionic-Angular-Usage.md

0.0.1 (2021-07-13)

Chore

0.0.1-rc.1 (2021-05-16)

Chore

0.0.1-beta.3 (2021-03-28)

Bug fixes

  • fix issue with jeep-photoviewer loader

0.0.1-beta.2 (2021-03-27)

Chore

Added Features

  • Web plugin by using jeep-photoviewer Stencil component.
  • Add movie creation to iOS plugin

0.0.1-beta.1 (2021-03-08)

Chore

Added Features

  • Android Rotation Portrait to Landscape
  • Android Close button when image in fullscreen
  • Android Hiding Share and Close button on singleTap

0.0.1-alpha.2 (2021-03-06)

Added Features

  • iOS Reading Base64 images
  • iOS Sharing an image
  • iOS Gestures for Zooming in/out
  • maxzoomscale options
  • compression quality options

0.0.1-alpha.1 (2021-03-02)

  • Initial commit for Photoviewer Android and iOS