@capacitor-community/photoviewer

中文文档
8.0.1发布于 2026/06/04MITTypeScriptESM + CJS近 30 天下载 7884

PhotoViewer table images with fullscreen and sharing capabilities

原始使用文档
文档目录18 节
  1. PHOTO VIEWER
  2. Maintainers
  3. Browser Support
  4. Installation
  5. iOS
  6. Android
  7. Web, PWA
  8. Build your App
  9. Supported methods
  10. Documentation
  11. Applications demonstrating the use of the plugin
  12. Ionic/Angular
  13. Ionic/Vue
  14. React
  15. Usage
  16. iOS and Android
  17. Dependencies
  18. Contributors ✨


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

MaintainerGitHubSocial
Robin Genzrobingenz@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

NameAndroidiOSElectronWeb
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!

版本与发布记录

@capacitor-community/photoviewer 共发布 53 个版本,首次发布于 2021/03/02;过去 12 个月发布了 2 个版本。

版本发布日期距今
8.0.1latest2026/06/045 个月前
8.0.02026/01/129 个月前
7.1.02025/10/241 年前
7.0.02025/03/141.7 年前
3.2.1latest-32024/09/042 年前
4.0.12024/09/042 年前

其他发布通道:next → 3.0.0-beta.1,latest-3 → 3.2.1。

关于 @capacitor-community/photoviewer 的常见问题

@capacitor-community/photoviewer 是什么?

PhotoViewer table images with fullscreen and sharing capabilities

如何安装 @capacitor-community/photoviewer?

在项目目录运行 npm install @capacitor-community/photoviewer,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@capacitor/core(>=8.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@capacitor-community/photoviewer 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@capacitor-community/photoviewer 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@capacitor-community/photoviewer 可以商用吗?

@capacitor-community/photoviewer 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@capacitor-community/photoviewer 的下载量有多少?

根据 npm 官方下载统计,@capacitor-community/photoviewer 在 2026/10/09 – 2026/11/07 这 30 天内被下载 7,884 次,日均约 263 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@capacitor-community/photoviewer 还在维护吗?

最新版本 8.0.1 发布于 2026/06/04(5 个月前);至今共发布 53 个版本,其中过去 12 个月发布了 2 个;首次发布于 2021/03/02。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。