mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
48 lines
55 KiB
HTML
48 lines
55 KiB
HTML
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
<meta name="generator" content="Docusaurus v2.0.0-alpha.66">
|
|
<link rel="alternate" type="application/rss+xml" href="/blog/rss.xml" title="React Native Blog RSS Feed">
|
|
<link rel="alternate" type="application/atom+xml" href="/blog/atom.xml" title="React Native Blog Atom Feed">
|
|
<link rel="preconnect" href="https://www.google-analytics.com">
|
|
<script>window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)},ga.l=+new Date,ga("create","UA-41298772-2","auto"),ga("send","pageview")</script>
|
|
<script async src="https://www.google-analytics.com/analytics.js"></script>
|
|
<link rel="preconnect" href="https://www.google-analytics.com">
|
|
<link rel="preconnect" href="https://www.googletagmanager.com">
|
|
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-41298772-2"></script>
|
|
<script>function gtag(){dataLayer.push(arguments)}window.dataLayer=window.dataLayer||[],gtag("js",new Date),gtag("config","UA-41298772-2",{})</script>
|
|
<link rel="search" type="application/opensearchdescription+xml" title="React Native" href="/opensearch.xml">
|
|
<script src="https://cdn.jsdelivr.net/npm/focus-visible@5.0.2/dist/focus-visible.min.js" defer="defer"></script>
|
|
<script src="https://snack.expo.io/embed.js" defer="defer"></script><title data-react-helmet="true">Image · React Native</title><meta data-react-helmet="true" property="twitter:image" content="https://reactnative.dev/img/logo-og.png"><meta data-react-helmet="true" name="twitter:image:alt" content="Image for React Native"><meta data-react-helmet="true" name="docsearch:language" content="en"><meta data-react-helmet="true" name="docsearch:version" content="0.63"><meta data-react-helmet="true" name="docsearch:docusaurus_tag" content="docs-default-0.63"><meta data-react-helmet="true" property="og:image" content="https://reactnative.dev/img/logo-og.png"><meta data-react-helmet="true" name="twitter:card" content="summary"><meta data-react-helmet="true" name="twitter:image" content="https://reactnative.dev/img/logo-og.png"><meta data-react-helmet="true" property="og:title" content="Image · React Native"><meta data-react-helmet="true" name="description" content="A React component for displaying different types of images, including network images, static resources, temporary local images, and images from local disk, such as the camera roll."><meta data-react-helmet="true" property="og:description" content="A React component for displaying different types of images, including network images, static resources, temporary local images, and images from local disk, such as the camera roll."><meta data-react-helmet="true" property="og:url" content="https://reactnative.dev/docs/image"><link data-react-helmet="true" rel="shortcut icon" href="/img/favicon.ico"><link data-react-helmet="true" rel="preconnect" href="https://BH4D9OD16A-dsn.algolia.net" crossorigin="anonymous"><link data-react-helmet="true" rel="canonical" href="https://reactnative.dev/docs/image"><link rel="stylesheet" href="/styles.fccefeba.css">
|
|
<link rel="stylesheet" href="/main.81698b96.css">
|
|
<link rel="preload" href="/styles.73cf9778.js" as="script">
|
|
<link rel="preload" href="/runtime~main.247cada2.js" as="script">
|
|
<link rel="preload" href="/main.3b1f3498.js" as="script">
|
|
<link rel="preload" href="/1.17a0cf36.js" as="script">
|
|
<link rel="preload" href="/2.37a050b1.js" as="script">
|
|
<link rel="preload" href="/1f391b9e.c148b120.js" as="script">
|
|
<link rel="preload" href="/939.41ec4d67.js" as="script">
|
|
<link rel="preload" href="/ee5b3385.90d27433.js" as="script">
|
|
<link rel="preload" href="/17896441.7d7633c0.js" as="script">
|
|
<link rel="preload" href="/11b5c5a7.2ed9fd34.js" as="script">
|
|
</head>
|
|
<body>
|
|
<script>!function(){function t(t){document.documentElement.setAttribute("data-theme",t)}var e=function(){var t=null;try{t=localStorage.getItem("theme")}catch(t){}return t}();t(null!==e?e:"light")}()</script><div id="__docusaurus">
|
|
<nav class="navbar navbar--fixed-top navbar--dark"><div class="navbar__inner"><div class="navbar__items"><div aria-label="Navigation bar toggle" class="navbar__toggle" role="button" tabindex="0"><svg xmlns="http://www.w3.org/2000/svg" width="30" height="30" viewBox="0 0 30 30" role="img" focusable="false"><title>Menu</title><path stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M4 7h22M4 15h22M4 23h22"></path></svg></div><a class="navbar__brand" href="/"><img class="navbar__logo" src="/img/header_logo.svg" alt="React Native"><strong class="navbar__title">React Native</strong></a><div class="navbar__item dropdown dropdown--hoverable dropdown--left"><a class="navbar__item navbar__link" href="/docs/getting-started">0.63</a><ul class="dropdown__menu"><li><a class="dropdown__link" href="/docs/next/image">Next</a></li><li><a aria-current="page" class="dropdown__link dropdown__link--active" href="/docs/image">0.63</a></li><li><a class="dropdown__link" href="/docs/0.62/image">0.62</a></li><li><a class="dropdown__link" href="/docs/0.61/image">0.61</a></li><li><a class="dropdown__link" href="/docs/0.60/image">0.60</a></li><li><a class="dropdown__link" href="/versions">All versions</a></li></ul></div></div><div class="navbar__items navbar__items--right"><a class="navbar__item navbar__link" href="/docs/getting-started">Docs</a><a class="navbar__item navbar__link navbar__link--active" href="/docs/components-and-apis">Components</a><a class="navbar__item navbar__link" href="/docs/accessibilityinfo">API</a><a class="navbar__item navbar__link" href="/help">Community</a><a class="navbar__item navbar__link" href="/blog">Blog</a><a href="https://github.com/facebook/react-native" target="_blank" rel="noopener noreferrer" class="navbar__item navbar__link navbar-github-link" aria-label="GitHub repository"></a><div class="react-toggle react-toggle--disabled displayOnlyInLargeViewport_3lWe"><div class="react-toggle-track"><div class="react-toggle-track-check"><span class="toggle_gnXW">🌜</span></div><div class="react-toggle-track-x"><span class="toggle_gnXW">🌞</span></div></div><div class="react-toggle-thumb"></div><input type="checkbox" disabled="" aria-label="Dark mode toggle" class="react-toggle-screenreader-only"></div><button type="button" class="DocSearch DocSearch-Button" aria-label="Search"><svg width="20" height="20" class="DocSearch-Search-Icon" viewBox="0 0 20 20"><path d="M14.386 14.386l4.0877 4.0877-4.0877-4.0877c-2.9418 2.9419-7.7115 2.9419-10.6533 0-2.9419-2.9418-2.9419-7.7115 0-10.6533 2.9418-2.9419 7.7115-2.9419 10.6533 0 2.9419 2.9418 2.9419 7.7115 0 10.6533z" stroke="currentColor" fill="none" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round"></path></svg><span class="DocSearch-Button-Placeholder">Search</span><span class="DocSearch-Button-Key">⌘</span><span class="DocSearch-Button-Key">K</span></button></div></div><div role="presentation" class="navbar-sidebar__backdrop"></div><div class="navbar-sidebar"><div class="navbar-sidebar__brand"><a class="navbar__brand" href="/"><img class="navbar__logo" src="/img/header_logo.svg" alt="React Native"><strong class="navbar__title">React Native</strong></a></div><div class="navbar-sidebar__items"><div class="menu"><ul class="menu__list"><li class="menu__list-item"><a class="menu__link" href="/docs/getting-started">Docs</a></li><li class="menu__list-item"><a class="menu__link navbar__link--active" href="/docs/components-and-apis">Components</a></li><li class="menu__list-item"><a class="menu__link" href="/docs/accessibilityinfo">API</a></li><li class="menu__list-item"><a class="menu__link" href="/help">Community</a></li><li class="menu__list-item"><a class="menu__link" href="/blog">Blog</a></li><li class="menu__list-item"><a role="button" class="menu__link menu__link--sublist">Versions</a><ul class="menu__list"><li class="menu__list-item"><a class="menu__link" href="/docs/next/image">Next</a></li><li class="menu__list-item"><a aria-current="page" class="menu__link menu__link--active" href="/docs/image">0.63</a></li><li class="menu__list-item"><a class="menu__link" href="/docs/0.62/image">0.62</a></li><li class="menu__list-item"><a class="menu__link" href="/docs/0.61/image">0.61</a></li><li class="menu__list-item"><a class="menu__link" href="/docs/0.60/image">0.60</a></li><li class="menu__list-item"><a class="menu__link" href="/versions">All versions</a></li></ul></li><li class="menu__list-item"><a href="https://github.com/facebook/react-native" target="_blank" rel="noopener noreferrer" class="menu__link navbar-github-link" aria-label="GitHub repository"></a></li></ul></div></div></div></nav><div class="main-wrapper"><div class="docPage_2UBv"><div class="docSidebarContainer_1hqR" role="complementary"><div class="sidebar_MSwm"><div class="menu menu--responsive menu_2hiu"><button aria-label="Open Menu" aria-haspopup="true" class="button button--secondary button--sm menu__button" type="button"><svg aria-label="Menu" class="sidebarMenuIcon_37TU" xmlns="http://www.w3.org/2000/svg" height="24" width="24" viewBox="0 0 32 32" role="img" focusable="false"><title>Menu</title><path stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M4 7h22M4 15h22M4 23h22"></path></svg></button><ul class="menu__list"><li class="menu__list-item"><a class="menu__link menu__link--sublist menu__link--active" href="#!">Core Components</a><ul class="menu__list"><li class="menu__list-item"><a class="menu__link" tabindex="0" href="/docs/components-and-apis">Core Components and APIs</a></li><li class="menu__list-item"><a class="menu__link" tabindex="0" href="/docs/activityindicator">ActivityIndicator</a></li><li class="menu__list-item"><a class="menu__link" tabindex="0" href="/docs/button">Button</a></li><li class="menu__list-item"><a class="menu__link" tabindex="0" href="/docs/flatlist">FlatList</a></li><li class="menu__list-item"><a aria-current="page" class="menu__link menu__link--active active" tabindex="0" href="/docs/image">Image</a></li><li class="menu__list-item"><a class="menu__link" tabindex="0" href="/docs/imagebackground">ImageBackground</a></li><li class="menu__list-item"><a class="menu__link" tabindex="0" href="/docs/keyboardavoidingview">KeyboardAvoidingView</a></li><li class="menu__list-item"><a class="menu__link" tabindex="0" href="/docs/modal">Modal</a></li><li class="menu__list-item"><a class="menu__link" tabindex="0" href="/docs/pressable">Pressable</a></li><li class="menu__list-item"><a class="menu__link" tabindex="0" href="/docs/refreshcontrol">RefreshControl</a></li><li class="menu__list-item"><a class="menu__link" tabindex="0" href="/docs/scrollview">ScrollView</a></li><li class="menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sectionlist">SectionList</a></li><li class="menu__list-item"><a class="menu__link" tabindex="0" href="/docs/statusbar">StatusBar</a></li><li class="menu__list-item"><a class="menu__link" tabindex="0" href="/docs/switch">Switch</a></li><li class="menu__list-item"><a class="menu__link" tabindex="0" href="/docs/text">Text</a></li><li class="menu__list-item"><a class="menu__link" tabindex="0" href="/docs/textinput">TextInput</a></li><li class="menu__list-item"><a class="menu__link" tabindex="0" href="/docs/touchablehighlight">TouchableHighlight</a></li><li class="menu__list-item"><a class="menu__link" tabindex="0" href="/docs/touchableopacity">TouchableOpacity</a></li><li class="menu__list-item"><a class="menu__link" tabindex="0" href="/docs/touchablewithoutfeedback">TouchableWithoutFeedback</a></li><li class="menu__list-item"><a class="menu__link" tabindex="0" href="/docs/view">View</a></li><li class="menu__list-item"><a class="menu__link" tabindex="0" href="/docs/virtualizedlist">VirtualizedList</a></li><li class="menu__list-item"><a class="menu__link menu__link--sublist" href="#!" tabindex="0">Android Components</a><ul class="menu__list"><li class="menu__list-item"><a class="menu__link" tabindex="0" href="/docs/drawerlayoutandroid">DrawerLayoutAndroid</a></li><li class="menu__list-item"><a class="menu__link" tabindex="0" href="/docs/touchablenativefeedback">TouchableNativeFeedback</a></li></ul></li><li class="menu__list-item"><a class="menu__link menu__link--sublist" href="#!" tabindex="0">iOS Components</a><ul class="menu__list"><li class="menu__list-item"><a class="menu__link" tabindex="0" href="/docs/inputaccessoryview">InputAccessoryView</a></li><li class="menu__list-item"><a class="menu__link" tabindex="0" href="/docs/maskedviewios">🚧 MaskedViewIOS</a></li><li class="menu__list-item"><a class="menu__link" tabindex="0" href="/docs/safeareaview">SafeAreaView</a></li></ul></li></ul></li><li class="menu__list-item menu__list-item--collapsed"><a class="menu__link menu__link--sublist" href="#!">Props</a><ul class="menu__list"><li class="menu__list-item"><a class="menu__link" tabindex="-1" href="/docs/image-style-props">Image Style Props</a></li><li class="menu__list-item"><a class="menu__link" tabindex="-1" href="/docs/layout-props">Layout Props</a></li><li class="menu__list-item"><a class="menu__link" tabindex="-1" href="/docs/shadow-props">Shadow Props</a></li><li class="menu__list-item"><a class="menu__link" tabindex="-1" href="/docs/text-style-props">Text Style Props</a></li><li class="menu__list-item"><a class="menu__link" tabindex="-1" href="/docs/view-style-props">View Style Props</a></li></ul></li><li class="menu__list-item menu__list-item--collapsed"><a class="menu__link menu__link--sublist" href="#!">Object Types</a><ul class="menu__list"><li class="menu__list-item"><a class="menu__link" tabindex="-1" href="/docs/pressevent">PressEvent Object Type</a></li><li class="menu__list-item"><a class="menu__link" tabindex="-1" href="/docs/react-node">React Node Object Type</a></li><li class="menu__list-item"><a class="menu__link" tabindex="-1" href="/docs/rect">Rect Object Type</a></li></ul></li></ul></div></div></div><main class="docMainContainer_1rYT"><div class="container padding-vert--lg docItemWrapper_1Hme"><div class="row"><div class="col docItemCol_2AGf"><div class="docItemContainer_1tAC"><article><header><h1 class="docTitle_cWlf">Image</h1></header><div class="markdown"><p>A React component for displaying different types of images, including network images, static resources, temporary local images, and images from local disk, such as the camera roll.</p><p>This example shows fetching and displaying an image from local storage as well as one from network and even from data provided in the <code>'data:'</code> uri scheme.</p><blockquote><p>Note that for network and data images, you will need to manually specify the dimensions of your image!</p></blockquote><h2><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_3pqN" id="examples"></a>Examples<a aria-hidden="true" tabindex="-1" class="hash-link" href="#examples" title="Direct link to heading">#</a></h2><div><ul role="tablist" aria-orientation="horizontal" class="tabs"><li role="tab" tabindex="0" aria-selected="true" class="tabs__item tabItem_3gSF tabs__item--active" style="outline:none">Function Component</li><li role="tab" tabindex="0" aria-selected="false" class="tabs__item tabItem_3gSF" style="outline:none">Class Component</li></ul><div role="tabpanel" class="margin-vert--md"><div><div class="snack-player" data-snack-name="Function Component Example" data-snack-description="Example usage" data-snack-code="%0Aimport%20React%20from%20'react'%3B%0Aimport%20%7B%20View%2C%20Image%2C%20StyleSheet%20%7D%20from%20'react-native'%3B%0A%0Aconst%20styles%20%3D%20StyleSheet.create(%7B%0A%20%20container%3A%20%7B%0A%20%20%20%20paddingTop%3A%2050%2C%0A%20%20%7D%2C%0A%20%20tinyLogo%3A%20%7B%0A%20%20%20%20width%3A%2050%2C%0A%20%20%20%20height%3A%2050%2C%0A%20%20%7D%2C%0A%20%20logo%3A%20%7B%0A%20%20%20%20width%3A%2066%2C%0A%20%20%20%20height%3A%2058%2C%0A%20%20%7D%2C%0A%7D)%3B%0A%0Aconst%20DisplayAnImage%20%3D%20()%20%3D%3E%20%7B%0A%20%20return%20(%0A%20%20%20%20%3CView%20style%3D%7Bstyles.container%7D%3E%0A%20%20%20%20%20%20%3CImage%0A%20%20%20%20%20%20%20%20style%3D%7Bstyles.tinyLogo%7D%0A%20%20%20%20%20%20%20%20source%3D%7Brequire('%40expo%2Fsnack-static%2Freact-native-logo.png')%7D%0A%20%20%20%20%20%20%2F%3E%0A%20%20%20%20%20%20%3CImage%0A%20%20%20%20%20%20%20%20style%3D%7Bstyles.tinyLogo%7D%0A%20%20%20%20%20%20%20%20source%3D%7B%7B%0A%20%20%20%20%20%20%20%20%20%20uri%3A%20'https%3A%2F%2Freactnative.dev%2Fimg%2Ftiny_logo.png'%2C%0A%20%20%20%20%20%20%20%20%7D%7D%0A%20%20%20%20%20%20%2F%3E%0A%20%20%20%20%20%20%3CImage%0A%20%20%20%20%20%20%20%20style%3D%7Bstyles.logo%7D%0A%20%20%20%20%20%20%20%20source%3D%7B%7B%0A%20%20%20%20%20%20%20%20%20%20uri%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20'data%3Aimage%2Fpng%3Bbase64%2CiVBORw0KGgoAAAANSUhEUgAAADMAAAAzCAYAAAA6oTAqAAAAEXRFWHRTb2Z0d2FyZQBwbmdjcnVzaEB1SfMAAABQSURBVGje7dSxCQBACARB%2B2%2Fab8BEeQNhFi6WSYzYLYudDQYGBgYGBgYGBgYGBgYGBgZmcvDqYGBgmhivGQYGBgYGBgYGBgYGBgYGBgbmQw%2BP%2FeMrC5UTVAAAAABJRU5ErkJggg%3D%3D'%2C%0A%20%20%20%20%20%20%20%20%7D%7D%0A%20%20%20%20%20%20%2F%3E%0A%20%20%20%20%3C%2FView%3E%0A%20%20)%3B%0A%7D%0A%0Aexport%20default%20DisplayAnImage%3B" data-snack-platform="web" data-snack-supported-platforms="ios,android,web" data-snack-theme="light" data-snack-preview="true"></div></div></div></div><p>You can also add <code>style</code> to an image:</p><div><ul role="tablist" aria-orientation="horizontal" class="tabs"><li role="tab" tabindex="0" aria-selected="true" class="tabs__item tabItem_3gSF tabs__item--active" style="outline:none">Function Component</li><li role="tab" tabindex="0" aria-selected="false" class="tabs__item tabItem_3gSF" style="outline:none">Class Component</li></ul><div role="tabpanel" class="margin-vert--md"><div><div class="snack-player" data-snack-name="Function Component Example" data-snack-description="Example usage" data-snack-code="%0Aimport%20React%20from%20'react'%3B%0Aimport%20%7B%20View%2C%20Image%2C%20StyleSheet%20%7D%20from%20'react-native'%3B%0A%0Aconst%20styles%20%3D%20StyleSheet.create(%7B%0A%20%20container%3A%20%7B%0A%20%20%20%20paddingTop%3A%2050%2C%0A%20%20%7D%2C%0A%20%20stretch%3A%20%7B%0A%20%20%20%20width%3A%2050%2C%0A%20%20%20%20height%3A%20200%2C%0A%20%20%20%20resizeMode%3A%20'stretch'%2C%0A%20%20%7D%2C%0A%7D)%3B%0A%0Aconst%20DisplayAnImageWithStyle%20%3D%20()%20%3D%3E%20%7B%0A%20%20return%20(%0A%20%20%20%20%3CView%20style%3D%7Bstyles.container%7D%3E%0A%20%20%20%20%20%20%3CImage%0A%20%20%20%20%20%20%20%20style%3D%7Bstyles.stretch%7D%0A%20%20%20%20%20%20%20%20source%3D%7Brequire('%40expo%2Fsnack-static%2Freact-native-logo.png')%7D%0A%20%20%20%20%20%20%2F%3E%0A%20%20%20%20%3C%2FView%3E%0A%20%20)%3B%0A%7D%0A%0Aexport%20default%20DisplayAnImageWithStyle%3B" data-snack-platform="web" data-snack-supported-platforms="ios,android,web" data-snack-theme="light" data-snack-preview="true"></div></div></div></div><h2><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_3pqN" id="gif-and-webp-support-on-android"></a>GIF and WebP support on Android<a aria-hidden="true" tabindex="-1" class="hash-link" href="#gif-and-webp-support-on-android" title="Direct link to heading">#</a></h2><p>When building your own native code, GIF and WebP are not supported by default on Android.</p><p>You will need to add some optional modules in <code>android/app/build.gradle</code>, depending on the needs of your app.</p><div class="mdxCodeBlock_xYIz"><div class="codeBlockContent_rlEb"><button tabindex="0" type="button" aria-label="Copy code to clipboard" class="copyButton_kOW4">Copy</button><div class="prism-code language-gradle codeBlock_1AP7"><div class="codeBlockLines_1boI" style="color:#FFFFFF;background:#282C34"><div class="token-line" style="color:#FFFFFF;background:#282C34"><span class="token plain">dependencies {</span></div><div class="token-line" style="color:#FFFFFF;background:#282C34"><span class="token plain"> // If your app supports Android versions before Ice Cream Sandwich (API level 14)</span></div><div class="token-line" style="color:#FFFFFF;background:#282C34"><span class="token plain"> implementation 'com.facebook.fresco:animated-base-support:1.3.0'</span></div><div class="token-line" style="color:#FFFFFF;background:#282C34"><span class="token plain" style="display:inline-block">
|
|
</span></div><div class="token-line" style="color:#FFFFFF;background:#282C34"><span class="token plain"> // For animated GIF support</span></div><div class="token-line" style="color:#FFFFFF;background:#282C34"><span class="token plain"> implementation 'com.facebook.fresco:animated-gif:2.0.0'</span></div><div class="token-line" style="color:#FFFFFF;background:#282C34"><span class="token plain" style="display:inline-block">
|
|
</span></div><div class="token-line" style="color:#FFFFFF;background:#282C34"><span class="token plain"> // For WebP support, including animated WebP</span></div><div class="token-line" style="color:#FFFFFF;background:#282C34"><span class="token plain"> implementation 'com.facebook.fresco:animated-webp:2.1.0'</span></div><div class="token-line" style="color:#FFFFFF;background:#282C34"><span class="token plain"> implementation 'com.facebook.fresco:webpsupport:2.0.0'</span></div><div class="token-line" style="color:#FFFFFF;background:#282C34"><span class="token plain" style="display:inline-block">
|
|
</span></div><div class="token-line" style="color:#FFFFFF;background:#282C34"><span class="token plain"> // For WebP support, without animations</span></div><div class="token-line" style="color:#FFFFFF;background:#282C34"><span class="token plain"> implementation 'com.facebook.fresco:webpsupport:2.0.0'</span></div><div class="token-line" style="color:#FFFFFF;background:#282C34"><span class="token plain">}</span></div></div></div></div></div><hr><h1><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_3pqN" id="reference"></a>Reference<a aria-hidden="true" tabindex="-1" class="hash-link" href="#reference" title="Direct link to heading">#</a></h1><h2><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_3pqN" id="props"></a>Props<a aria-hidden="true" tabindex="-1" class="hash-link" href="#props" title="Direct link to heading">#</a></h2><h3><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_3pqN" id="style"></a><code>style</code><a aria-hidden="true" tabindex="-1" class="hash-link" href="#style" title="Direct link to heading">#</a></h3><p><code>ImageResizeMode</code> is an <code>Enum</code> for different image resizing modes, set via the <code>resizeMode</code> style property on <code>Image</code> components. The values are <code>contain</code>, <code>cover</code>, <code>stretch</code>, <code>center</code>, <code>repeat</code>.</p><table><thead><tr><th>Type</th><th>Required</th></tr></thead><tbody><tr><td>style</td><td>No</td></tr></tbody></table><ul><li><p><a href="/docs/image-style-props#props">Image Style Props...</a></p></li><li><p><a href="/docs/layout-props#props">Layout Props...</a></p></li><li><p><a href="/docs/shadow-props#props">Shadow Props...</a></p></li><li><p><a href="/docs/transforms#props">Transforms...</a></p></li></ul><hr><h3><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_3pqN" id="accessible"></a><code>accessible</code><a aria-hidden="true" tabindex="-1" class="hash-link" href="#accessible" title="Direct link to heading">#</a></h3><p>When true, indicates the image is an accessibility element.</p><table><thead><tr><th>Type</th><th>Required</th><th>Platform</th></tr></thead><tbody><tr><td>bool</td><td>No</td><td>iOS</td></tr></tbody></table><hr><h3><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_3pqN" id="accessibilitylabel"></a><code>accessibilityLabel</code><a aria-hidden="true" tabindex="-1" class="hash-link" href="#accessibilitylabel" title="Direct link to heading">#</a></h3><p>The text that's read by the screen reader when the user interacts with the image.</p><table><thead><tr><th>Type</th><th>Required</th><th>Platform</th></tr></thead><tbody><tr><td>string</td><td>No</td><td>iOS</td></tr></tbody></table><hr><h3><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_3pqN" id="blurradius"></a><code>blurRadius</code><a aria-hidden="true" tabindex="-1" class="hash-link" href="#blurradius" title="Direct link to heading">#</a></h3><p>blurRadius: the blur radius of the blur filter added to the image</p><table><thead><tr><th>Type</th><th>Required</th></tr></thead><tbody><tr><td>number</td><td>No</td></tr></tbody></table><blockquote><p>Tip : IOS you will need to increase <code>blurRadius</code> more than <code>5</code></p></blockquote><hr><h3><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_3pqN" id="capinsets"></a><code>capInsets</code><a aria-hidden="true" tabindex="-1" class="hash-link" href="#capinsets" title="Direct link to heading">#</a></h3><p>When the image is resized, the corners of the size specified by <code>capInsets</code> will stay a fixed size, but the center content and borders of the image will be stretched. This is useful for creating resizable rounded buttons, shadows, and other resizable assets. More info in the <a href="https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIImage_Class/index.html#//apple_ref/occ/instm/UIImage/resizableImageWithCapInsets" target="_blank" rel="noopener noreferrer">official Apple documentation</a>.</p><table><thead><tr><th>Type</th><th>Required</th><th>Platform</th></tr></thead><tbody><tr><td><a href="/docs/rect">Rect</a></td><td>No</td><td>iOS</td></tr></tbody></table><hr><h3><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_3pqN" id="defaultsource"></a><code>defaultSource</code><a aria-hidden="true" tabindex="-1" class="hash-link" href="#defaultsource" title="Direct link to heading">#</a></h3><p>A static image to display while loading the image source.</p><table><thead><tr><th>Type</th><th>Required</th><th>Platform</th></tr></thead><tbody><tr><td>object, number</td><td>No</td><td>iOS</td></tr><tr><td>number</td><td>No</td><td>Android</td></tr></tbody></table><p>If passing an object, the general shape is <code>{uri: string, width: number, height: number, scale: number}</code>:</p><ul><li><code>uri</code> - a string representing the resource identifier for the image, which should be either a local file path or the name of a static image resource (which should be wrapped in the <code>require('./path/to/image.png')</code> function).</li><li><code>width</code>, <code>height</code> - can be specified if known at build time, in which case these will be used to set the default <code><Image/></code> component dimensions.</li><li><code>scale</code> - used to indicate the scale factor of the image. Defaults to 1.0 if unspecified, meaning that one image pixel equates to one display point / DIP.</li></ul><p>If passing a number:</p><ul><li><code>number</code> - Opaque type returned by something like <code>require('./image.jpg')</code>.</li></ul><blockquote><p><strong>Note:</strong> On Android, the default source prop is ignored on debug builds.</p></blockquote><hr><h3><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_3pqN" id="fadeduration"></a><code>fadeDuration</code><a aria-hidden="true" tabindex="-1" class="hash-link" href="#fadeduration" title="Direct link to heading">#</a></h3><p>Android only. By default, it is 300ms.</p><table><thead><tr><th>Type</th><th>Required</th><th>Platform</th></tr></thead><tbody><tr><td>number</td><td>No</td><td>Android</td></tr></tbody></table><hr><h3><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_3pqN" id="loadingindicatorsource"></a><code>loadingIndicatorSource</code><a aria-hidden="true" tabindex="-1" class="hash-link" href="#loadingindicatorsource" title="Direct link to heading">#</a></h3><p>Similarly to <code>source</code>, this property represents the resource used to render the loading indicator for the image, displayed until image is ready to be displayed, typically after when it got downloaded from network.</p><table><thead><tr><th>Type</th><th>Required</th></tr></thead><tbody><tr><td>array of ImageSourcePropTypes, number</td><td>No</td></tr></tbody></table><blockquote><p>Can accept a number as returned by <code>require('./image.jpg')</code></p></blockquote><hr><h3><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_3pqN" id="onerror"></a><code>onError</code><a aria-hidden="true" tabindex="-1" class="hash-link" href="#onerror" title="Direct link to heading">#</a></h3><p>Invoked on load error with <code>{nativeEvent: {error}}</code>.</p><table><thead><tr><th>Type</th><th>Required</th></tr></thead><tbody><tr><td>function</td><td>No</td></tr></tbody></table><hr><h3><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_3pqN" id="onlayout"></a><code>onLayout</code><a aria-hidden="true" tabindex="-1" class="hash-link" href="#onlayout" title="Direct link to heading">#</a></h3><p>Invoked on mount and layout changes with <code>{nativeEvent: {layout: {x, y, width, height}}}</code>.</p><table><thead><tr><th>Type</th><th>Required</th></tr></thead><tbody><tr><td>function</td><td>No</td></tr></tbody></table><hr><h3><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_3pqN" id="onload"></a><code>onLoad</code><a aria-hidden="true" tabindex="-1" class="hash-link" href="#onload" title="Direct link to heading">#</a></h3><p>Invoked when load completes successfully.</p><table><thead><tr><th>Type</th><th>Required</th></tr></thead><tbody><tr><td>function</td><td>No</td></tr></tbody></table><hr><h3><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_3pqN" id="onloadend"></a><code>onLoadEnd</code><a aria-hidden="true" tabindex="-1" class="hash-link" href="#onloadend" title="Direct link to heading">#</a></h3><p>Invoked when load either succeeds or fails.</p><table><thead><tr><th>Type</th><th>Required</th></tr></thead><tbody><tr><td>function</td><td>No</td></tr></tbody></table><hr><h3><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_3pqN" id="onloadstart"></a><code>onLoadStart</code><a aria-hidden="true" tabindex="-1" class="hash-link" href="#onloadstart" title="Direct link to heading">#</a></h3><p>Invoked on load start.</p><p>e.g., <code>onLoadStart={(e) => this.setState({loading: true})}</code></p><table><thead><tr><th>Type</th><th>Required</th></tr></thead><tbody><tr><td>function</td><td>No</td></tr></tbody></table><hr><h3><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_3pqN" id="onpartialload"></a><code>onPartialLoad</code><a aria-hidden="true" tabindex="-1" class="hash-link" href="#onpartialload" title="Direct link to heading">#</a></h3><p>Invoked when a partial load of the image is complete. The definition of what constitutes a "partial load" is loader specific though this is meant for progressive JPEG loads.</p><table><thead><tr><th>Type</th><th>Required</th><th>Platform</th></tr></thead><tbody><tr><td>function</td><td>No</td><td>iOS</td></tr></tbody></table><hr><h3><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_3pqN" id="onprogress"></a><code>onProgress</code><a aria-hidden="true" tabindex="-1" class="hash-link" href="#onprogress" title="Direct link to heading">#</a></h3><p>Invoked on download progress with <code>{nativeEvent: {loaded, total}}</code>.</p><table><thead><tr><th>Type</th><th>Required</th><th>Platform</th></tr></thead><tbody><tr><td>function</td><td>No</td><td>iOS</td></tr></tbody></table><hr><h3><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_3pqN" id="progressiverenderingenabled"></a><code>progressiveRenderingEnabled</code><a aria-hidden="true" tabindex="-1" class="hash-link" href="#progressiverenderingenabled" title="Direct link to heading">#</a></h3><p>Android only. When true, enables progressive jpeg streaming. <a href="https://frescolib.org/docs/progressive-jpegs.html" target="_blank" rel="noopener noreferrer">https://frescolib.org/docs/progressive-jpegs.html</a></p><table><thead><tr><th>Type</th><th>Required</th><th>Platform</th></tr></thead><tbody><tr><td>bool</td><td>No</td><td>Android</td></tr></tbody></table><hr><h3><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_3pqN" id="resizemethod"></a><code>resizeMethod</code><a aria-hidden="true" tabindex="-1" class="hash-link" href="#resizemethod" title="Direct link to heading">#</a></h3><p>The mechanism that should be used to resize the image when the image's dimensions differ from the image view's dimensions. Defaults to <code>auto</code>.</p><ul><li><p><code>auto</code>: Use heuristics to pick between <code>resize</code> and <code>scale</code>.</p></li><li><p><code>resize</code>: A software operation which changes the encoded image in memory before it gets decoded. This should be used instead of <code>scale</code> when the image is much larger than the view.</p></li><li><p><code>scale</code>: The image gets drawn downscaled or upscaled. Compared to <code>resize</code>, <code>scale</code> is faster (usually hardware accelerated) and produces higher quality images. This should be used if the image is smaller than the view. It should also be used if the image is slightly bigger than the view.</p></li></ul><p>More details about <code>resize</code> and <code>scale</code> can be found at <a href="http://frescolib.org/docs/resizing.html" target="_blank" rel="noopener noreferrer">http://frescolib.org/docs/resizing.html</a>.</p><table><thead><tr><th>Type</th><th>Required</th><th>Platform</th></tr></thead><tbody><tr><td>enum('auto', 'resize', 'scale')</td><td>No</td><td>Android</td></tr></tbody></table><hr><h3><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_3pqN" id="resizemode"></a><code>resizeMode</code><a aria-hidden="true" tabindex="-1" class="hash-link" href="#resizemode" title="Direct link to heading">#</a></h3><p>Determines how to resize the image when the frame doesn't match the raw image dimensions. Defaults to <code>cover</code>.</p><ul><li><p><code>cover</code>: Scale the image uniformly (maintain the image's aspect ratio) so that both dimensions (width and height) of the image will be equal to or larger than the corresponding dimension of the view (minus padding).</p></li><li><p><code>contain</code>: Scale the image uniformly (maintain the image's aspect ratio) so that both dimensions (width and height) of the image will be equal to or less than the corresponding dimension of the view (minus padding).</p></li><li><p><code>stretch</code>: Scale width and height independently, This may change the aspect ratio of the src.</p></li><li><p><code>repeat</code>: Repeat the image to cover the frame of the view. The image will keep its size and aspect ratio, unless it is larger than the view, in which case it will be scaled down uniformly so that it is contained in the view.</p></li><li><p><code>center</code>: Center the image in the view along both dimensions. If the image is larger than the view, scale it down uniformly so that it is contained in the view.</p></li></ul><table><thead><tr><th>Type</th><th>Required</th></tr></thead><tbody><tr><td>enum('cover', 'contain', 'stretch', 'repeat', 'center')</td><td>No</td></tr></tbody></table><hr><h3><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_3pqN" id="source"></a><code>source</code><a aria-hidden="true" tabindex="-1" class="hash-link" href="#source" title="Direct link to heading">#</a></h3><p>The image source (either a remote URL or a local file resource).</p><p>This prop can also contain several remote URLs, specified together with their width and height and potentially with scale/other URI arguments. The native side will then choose the best <code>uri</code> to display based on the measured size of the image container. A <code>cache</code> property can be added to control how networked request interacts with the local cache. (For more information see <a href="/docs/images#cache-control-ios-only">Cache Control for Images</a>).</p><p>The currently supported formats are <code>png</code>, <code>jpg</code>, <code>jpeg</code>, <code>bmp</code>, <code>gif</code>, <code>webp</code> (Android only), <code>psd</code> (iOS only). In addition, iOS supports several RAW image formats. Refer to Apple's documentation for the current list of supported camera models (for iOS 12, see <a href="https://support.apple.com/en-ca/HT208967" target="_blank" rel="noopener noreferrer">https://support.apple.com/en-ca/HT208967</a>).</p><table><thead><tr><th>Type</th><th>Required</th></tr></thead><tbody><tr><td>ImageSourcePropType</td><td>No</td></tr></tbody></table><hr><h3><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_3pqN" id="testid"></a><code>testID</code><a aria-hidden="true" tabindex="-1" class="hash-link" href="#testid" title="Direct link to heading">#</a></h3><p>A unique identifier for this element to be used in UI Automation testing scripts.</p><table><thead><tr><th>Type</th><th>Required</th></tr></thead><tbody><tr><td>string</td><td>No</td></tr></tbody></table><h2><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_3pqN" id="methods"></a>Methods<a aria-hidden="true" tabindex="-1" class="hash-link" href="#methods" title="Direct link to heading">#</a></h2><h3><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_3pqN" id="getsize"></a><code>getSize()</code><a aria-hidden="true" tabindex="-1" class="hash-link" href="#getsize" title="Direct link to heading">#</a></h3><div class="mdxCodeBlock_xYIz"><div class="codeBlockContent_rlEb"><button tabindex="0" type="button" aria-label="Copy code to clipboard" class="copyButton_kOW4">Copy</button><div class="prism-code language-jsx codeBlock_1AP7"><div class="codeBlockLines_1boI" style="color:#FFFFFF;background:#282C34"><div class="token-line" style="color:#FFFFFF;background:#282C34"><span class="token plain">Image</span><span class="token punctuation" style="color:#657b83">.</span><span class="token function" style="color:#79b6f2">getSize</span><span class="token punctuation" style="color:#657b83">(</span><span class="token plain">uri</span><span class="token punctuation" style="color:#657b83">,</span><span class="token plain"> success</span><span class="token punctuation" style="color:#657b83">,</span><span class="token plain"> </span><span class="token punctuation" style="color:#657b83">[</span><span class="token plain">failure</span><span class="token punctuation" style="color:#657b83">]</span><span class="token punctuation" style="color:#657b83">)</span><span class="token punctuation" style="color:#657b83">;</span></div></div></div></div></div><p>Retrieve the width and height (in pixels) of an image prior to displaying it. This method can fail if the image cannot be found, or fails to download.</p><p>In order to retrieve the image dimensions, the image may first need to be loaded or downloaded, after which it will be cached. This means that in principle you could use this method to preload images, however it is not optimized for that purpose, and may in future be implemented in a way that does not fully load/download the image data. A proper, supported way to preload images will be provided as a separate API.</p><p><strong>Parameters:</strong></p><table><thead><tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td>uri</td><td>string</td><td>Yes</td><td>The location of the image.</td></tr><tr><td>success</td><td>function</td><td>Yes</td><td>The function that will be called if the image was successfully found and width and height retrieved.</td></tr><tr><td>failure</td><td>function</td><td>No</td><td>The function that will be called if there was an error, such as failing to retrieve the image.</td></tr></tbody></table><hr><h3><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_3pqN" id="getsizewithheaders"></a><code>getSizeWithHeaders()</code><a aria-hidden="true" tabindex="-1" class="hash-link" href="#getsizewithheaders" title="Direct link to heading">#</a></h3><div class="mdxCodeBlock_xYIz"><div class="codeBlockContent_rlEb"><button tabindex="0" type="button" aria-label="Copy code to clipboard" class="copyButton_kOW4">Copy</button><div class="prism-code language-jsx codeBlock_1AP7"><div class="codeBlockLines_1boI" style="color:#FFFFFF;background:#282C34"><div class="token-line" style="color:#FFFFFF;background:#282C34"><span class="token plain">Image</span><span class="token punctuation" style="color:#657b83">.</span><span class="token function" style="color:#79b6f2">getSizeWithHeaders</span><span class="token punctuation" style="color:#657b83">(</span><span class="token plain">uri</span><span class="token punctuation" style="color:#657b83">,</span><span class="token plain"> headers</span><span class="token punctuation" style="color:#657b83">,</span><span class="token plain"> success</span><span class="token punctuation" style="color:#657b83">,</span><span class="token plain"> </span><span class="token punctuation" style="color:#657b83">[</span><span class="token plain">failure</span><span class="token punctuation" style="color:#657b83">]</span><span class="token punctuation" style="color:#657b83">)</span><span class="token punctuation" style="color:#657b83">;</span></div></div></div></div></div><p>Retrieve the width and height (in pixels) of an image prior to displaying it with the ability to provide the headers for the request. This method can fail if the image cannot be found, or fails to download.</p><p>In order to retrieve the image dimensions, the image may first need to be loaded or downloaded, after which it will be cached. This means that in principle you could use this method to preload images, however it is not optimized for that purpose, and may in future be implemented in a way that does not fully load/download the image data. A proper, supported way to preload images will be provided as a separate API.</p><p>Does not work for static image resources.</p><p><strong>Parameters:</strong></p><table><thead><tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td>uri</td><td>string</td><td>Yes</td><td>The location of the image.</td></tr><tr><td>headers</td><td>object</td><td>Yes</td><td>The headers for the request.</td></tr><tr><td>success</td><td>function</td><td>Yes</td><td>The function that will be called if the image was successfully found and width and height retrieved.</td></tr><tr><td>failure</td><td>function</td><td>No</td><td>The function that will be called if there was an error, such as failing toto retrieve the image.</td></tr></tbody></table><hr><h3><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_3pqN" id="prefetch"></a><code>prefetch()</code><a aria-hidden="true" tabindex="-1" class="hash-link" href="#prefetch" title="Direct link to heading">#</a></h3><div class="mdxCodeBlock_xYIz"><div class="codeBlockContent_rlEb"><button tabindex="0" type="button" aria-label="Copy code to clipboard" class="copyButton_kOW4">Copy</button><div class="prism-code language-jsx codeBlock_1AP7"><div class="codeBlockLines_1boI" style="color:#FFFFFF;background:#282C34"><div class="token-line" style="color:#FFFFFF;background:#282C34"><span class="token plain">Image</span><span class="token punctuation" style="color:#657b83">.</span><span class="token function" style="color:#79b6f2">prefetch</span><span class="token punctuation" style="color:#657b83">(</span><span class="token plain">url</span><span class="token punctuation" style="color:#657b83">)</span><span class="token punctuation" style="color:#657b83">;</span></div></div></div></div></div><p>Prefetches a remote image for later use by downloading it to the disk cache</p><p><strong>Parameters:</strong></p><table><thead><tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td>url</td><td>string</td><td>Yes</td><td>The remote location of the image.</td></tr></tbody></table><hr><h3><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_3pqN" id="abortprefetch"></a><code>abortPrefetch()</code><a aria-hidden="true" tabindex="-1" class="hash-link" href="#abortprefetch" title="Direct link to heading">#</a></h3><div class="mdxCodeBlock_xYIz"><div class="codeBlockContent_rlEb"><button tabindex="0" type="button" aria-label="Copy code to clipboard" class="copyButton_kOW4">Copy</button><div class="prism-code language-jsx codeBlock_1AP7"><div class="codeBlockLines_1boI" style="color:#FFFFFF;background:#282C34"><div class="token-line" style="color:#FFFFFF;background:#282C34"><span class="token plain">Image</span><span class="token punctuation" style="color:#657b83">.</span><span class="token function" style="color:#79b6f2">abortPrefetch</span><span class="token punctuation" style="color:#657b83">(</span><span class="token plain">requestId</span><span class="token punctuation" style="color:#657b83">)</span><span class="token punctuation" style="color:#657b83">;</span></div></div></div></div></div><p>Abort prefetch request. Android-only.</p><p><strong>Parameters:</strong></p><table><thead><tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td>requestId</td><td>number</td><td>Yes</td><td>Id as returned by prefetch()</td></tr></tbody></table><hr><h3><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_3pqN" id="querycache"></a><code>queryCache()</code><a aria-hidden="true" tabindex="-1" class="hash-link" href="#querycache" title="Direct link to heading">#</a></h3><div class="mdxCodeBlock_xYIz"><div class="codeBlockContent_rlEb"><button tabindex="0" type="button" aria-label="Copy code to clipboard" class="copyButton_kOW4">Copy</button><div class="prism-code language-jsx codeBlock_1AP7"><div class="codeBlockLines_1boI" style="color:#FFFFFF;background:#282C34"><div class="token-line" style="color:#FFFFFF;background:#282C34"><span class="token plain">Image</span><span class="token punctuation" style="color:#657b83">.</span><span class="token function" style="color:#79b6f2">queryCache</span><span class="token punctuation" style="color:#657b83">(</span><span class="token plain">urls</span><span class="token punctuation" style="color:#657b83">)</span><span class="token punctuation" style="color:#657b83">;</span></div></div></div></div></div><p>Perform cache interrogation. Returns a mapping from URL to cache status, such as "disk" or "memory". If a requested URL is not in the mapping, it means it's not in the cache.</p><p><strong>Parameters:</strong></p><table><thead><tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td>urls</td><td>array</td><td>Yes</td><td>List of image URLs to check the cache for.</td></tr></tbody></table><hr><h3><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_3pqN" id="resolveassetsource"></a><code>resolveAssetSource()</code><a aria-hidden="true" tabindex="-1" class="hash-link" href="#resolveassetsource" title="Direct link to heading">#</a></h3><div class="mdxCodeBlock_xYIz"><div class="codeBlockContent_rlEb"><button tabindex="0" type="button" aria-label="Copy code to clipboard" class="copyButton_kOW4">Copy</button><div class="prism-code language-jsx codeBlock_1AP7"><div class="codeBlockLines_1boI" style="color:#FFFFFF;background:#282C34"><div class="token-line" style="color:#FFFFFF;background:#282C34"><span class="token plain">Image</span><span class="token punctuation" style="color:#657b83">.</span><span class="token function" style="color:#79b6f2">resolveAssetSource</span><span class="token punctuation" style="color:#657b83">(</span><span class="token plain">source</span><span class="token punctuation" style="color:#657b83">)</span><span class="token punctuation" style="color:#657b83">;</span></div></div></div></div></div><p>Resolves an asset reference into an object which has the properties <code>uri</code>, <code>width</code>, and <code>height</code>.</p><p><strong>Parameters:</strong></p><table><thead><tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td>source</td><td>number, object</td><td>Yes</td><td>A number (opaque type returned by require('./foo.png')) or an <code>ImageSource</code>.</td></tr></tbody></table><blockquote><p><code>ImageSource</code> is an object like <code>{ uri: '<http location || file path>' }</code></p></blockquote></div></article><div class="docMetadata margin-vert--xl"><div class="row"><div class="col"><a href="https://github.com/facebook/react-native-website/blob/master/website/versioned_docs/version-0.63/image.md" target="_blank" rel="noreferrer noopener"><svg fill="currentColor" height="1.2em" width="1.2em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 40 40" style="margin-right:0.3em;vertical-align:sub"><g><path d="m34.5 11.7l-3 3.1-6.3-6.3 3.1-3q0.5-0.5 1.2-0.5t1.1 0.5l3.9 3.9q0.5 0.4 0.5 1.1t-0.5 1.2z m-29.5 17.1l18.4-18.5 6.3 6.3-18.4 18.4h-6.3v-6.2z"></path></g></svg>Edit this page</a></div><div class="col text--right"><em><small class="docMetadata-updated">Last updated on <time datetime="2020-10-29T04:19:29.000Z" class="docLastUpdatedAt_1gIo">10/29/2020</time></small></em></div></div></div><div class="margin-vert--lg"><nav class="pagination-nav" aria-label="Blog list page navigation"><div class="pagination-nav__item"><a class="pagination-nav__link" href="/docs/flatlist"><div class="pagination-nav__sublabel">Previous</div><div class="pagination-nav__label">« FlatList</div></a></div><div class="pagination-nav__item pagination-nav__item--next"><a class="pagination-nav__link" href="/docs/imagebackground"><div class="pagination-nav__sublabel">Next</div><div class="pagination-nav__label">ImageBackground »</div></a></div></nav></div></div></div><div class="col col--3"><div class="tableOfContents_3iuQ"><ul class="table-of-contents table-of-contents__left-border"><li><a href="#examples" class="table-of-contents__link">Examples</a></li><li><a href="#gif-and-webp-support-on-android" class="table-of-contents__link">GIF and WebP support on Android</a></li><li><a href="#props" class="table-of-contents__link">Props</a><ul><li><a href="#style" class="table-of-contents__link"><code>style</code></a></li><li><a href="#accessible" class="table-of-contents__link"><code>accessible</code></a></li><li><a href="#accessibilitylabel" class="table-of-contents__link"><code>accessibilityLabel</code></a></li><li><a href="#blurradius" class="table-of-contents__link"><code>blurRadius</code></a></li><li><a href="#capinsets" class="table-of-contents__link"><code>capInsets</code></a></li><li><a href="#defaultsource" class="table-of-contents__link"><code>defaultSource</code></a></li><li><a href="#fadeduration" class="table-of-contents__link"><code>fadeDuration</code></a></li><li><a href="#loadingindicatorsource" class="table-of-contents__link"><code>loadingIndicatorSource</code></a></li><li><a href="#onerror" class="table-of-contents__link"><code>onError</code></a></li><li><a href="#onlayout" class="table-of-contents__link"><code>onLayout</code></a></li><li><a href="#onload" class="table-of-contents__link"><code>onLoad</code></a></li><li><a href="#onloadend" class="table-of-contents__link"><code>onLoadEnd</code></a></li><li><a href="#onloadstart" class="table-of-contents__link"><code>onLoadStart</code></a></li><li><a href="#onpartialload" class="table-of-contents__link"><code>onPartialLoad</code></a></li><li><a href="#onprogress" class="table-of-contents__link"><code>onProgress</code></a></li><li><a href="#progressiverenderingenabled" class="table-of-contents__link"><code>progressiveRenderingEnabled</code></a></li><li><a href="#resizemethod" class="table-of-contents__link"><code>resizeMethod</code></a></li><li><a href="#resizemode" class="table-of-contents__link"><code>resizeMode</code></a></li><li><a href="#source" class="table-of-contents__link"><code>source</code></a></li><li><a href="#testid" class="table-of-contents__link"><code>testID</code></a></li></ul></li><li><a href="#methods" class="table-of-contents__link">Methods</a><ul><li><a href="#getsize" class="table-of-contents__link"><code>getSize()</code></a></li><li><a href="#getsizewithheaders" class="table-of-contents__link"><code>getSizeWithHeaders()</code></a></li><li><a href="#prefetch" class="table-of-contents__link"><code>prefetch()</code></a></li><li><a href="#abortprefetch" class="table-of-contents__link"><code>abortPrefetch()</code></a></li><li><a href="#querycache" class="table-of-contents__link"><code>queryCache()</code></a></li><li><a href="#resolveassetsource" class="table-of-contents__link"><code>resolveAssetSource()</code></a></li></ul></li></ul></div></div></div></div></main></div></div><footer class="footer footer--dark"><div class="container"><div class="row footer__links"><div class="col footer__col"><h4 class="footer__title">Docs</h4><ul class="footer__items"><li class="footer__item"><a class="footer__link-item" href="/docs/getting-started">Getting Started</a></li><li class="footer__item"><a class="footer__link-item" href="/docs/tutorial">Tutorial</a></li><li class="footer__item"><a class="footer__link-item" href="/docs/components-and-apis">Components and APIs</a></li><li class="footer__item"><a class="footer__link-item" href="/docs/more-resources">More Resources</a></li></ul></div><div class="col footer__col"><h4 class="footer__title">Community</h4><ul class="footer__items"><li class="footer__item"><a class="footer__link-item" href="/help">The React Native Community</a></li><li class="footer__item"><a class="footer__link-item" href="/showcase">Who's using React Native?</a></li><li class="footer__item"><a href="https://stackoverflow.com/questions/tagged/react-native" target="_blank" rel="noopener noreferrer" class="footer__link-item">Ask Questions on Stack Overflow</a></li><li class="footer__item"><a href="https://github.com/facebook/react-native/blob/master/CONTRIBUTING.md" target="_blank" rel="noopener noreferrer" class="footer__link-item">Contributor Guide</a></li><li class="footer__item"><a href="https://dev.to/t/reactnative" target="_blank" rel="noopener noreferrer" class="footer__link-item">DEV Community</a></li></ul></div><div class="col footer__col"><h4 class="footer__title">Find us</h4><ul class="footer__items"><li class="footer__item"><a class="footer__link-item" href="/blog">Blog</a></li><li class="footer__item"><a href="https://twitter.com/reactnative" target="_blank" rel="noopener noreferrer" class="footer__link-item">Twitter</a></li><li class="footer__item"><a href="https://github.com/facebook/react-native" target="_blank" rel="noopener noreferrer" class="footer__link-item">GitHub</a></li></ul></div><div class="col footer__col"><h4 class="footer__title">More</h4><ul class="footer__items"><li class="footer__item"><a href="https://reactjs.org/" target="_blank" rel="noopener noreferrer" class="footer__link-item">React</a></li><li class="footer__item"><a href="https://opensource.facebook.com/legal/privacy" target="_blank" rel="noopener noreferrer" class="footer__link-item">Privacy Policy</a></li><li class="footer__item"><a href="https://opensource.facebook.com/legal/terms" target="_blank" rel="noopener noreferrer" class="footer__link-item">Terms of Service</a></li></ul></div></div><div class="text--center"><div class="margin-bottom--sm"><a href="https://opensource.facebook.com" target="_blank" rel="noopener noreferrer" class="footerLogoLink_19Ac"><img class="footer__logo" alt="Facebook Open Source Logo" src="/img/oss_logo.png"></a></div><div>Copyright © 2020 Facebook, Inc.</div></div></div></footer></div>
|
|
<script src="/styles.73cf9778.js"></script>
|
|
<script src="/runtime~main.247cada2.js"></script>
|
|
<script src="/main.3b1f3498.js"></script>
|
|
<script src="/1.17a0cf36.js"></script>
|
|
<script src="/2.37a050b1.js"></script>
|
|
<script src="/1f391b9e.c148b120.js"></script>
|
|
<script src="/939.41ec4d67.js"></script>
|
|
<script src="/ee5b3385.90d27433.js"></script>
|
|
<script src="/17896441.7d7633c0.js"></script>
|
|
<script src="/11b5c5a7.2ed9fd34.js"></script>
|
|
</body>
|
|
</html> |