-
Notifications
You must be signed in to change notification settings - Fork 24.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: added crossOrigin
, referrerPolicy
, srcSet
, width
, height
and src
props to the Image Component.
#34481
feat: added crossOrigin
, referrerPolicy
, srcSet
, width
, height
and src
props to the Image Component.
#34481
Conversation
Hi @dhruvtailor7! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks! |
Base commit: 4f6929b |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
Base commit: 4f6929b |
@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
Can we tackle all the new Image props at the same time, given that they all combine into the existing e.g., const { crossOrigin, height, referrerPolicy, src, srcSet, width } = props;
let source = null;
if (src != null) {
const headers = {};
if (crossOrigin === 'use-credentials') {
headers['Access-Control-Allow-Credentials'] = true;
}
if (referrerPolicy != null) {
headers['Referrer-Policy'] = referrerPolicy;
}
nextProps.progressiveRenderingEnabled = true;
source = { headers, height, uri: src, width };
}
if (srcSet != null) {
source = [];
const srcList = srcSet.split(', ');
srcList.forEach((src) => {
const [uri, xscale] = src.split(' ');
const scale = parseInt(xscale.split('x')[0], 10);
const headers = {};
if (crossOrigin === 'use-credentials') {
headers['Access-Control-Allow-Credentials'] = true;
}
if (referrerPolicy != null) {
headers['Referrer-Policy'] = referrerPolicy;
}
source.push({ headers, height, scale, uri, width });
});
} |
src
prop to source.uri
in Image ComponentcrossOrigin
, referrerPolicy
, srcSet
and src
props to the Image Component.
@necolas on Android, if we have multiple items in the |
The same width and height should be passed for each source |
@dhruvtailor7 are you planning to update this PR? Thanks |
@necolas Yes, I am still looking into the failing flow test cases. |
crossOrigin
, referrerPolicy
, srcSet
and src
props to the Image Component.crossOrigin
, referrerPolicy
, srcSet
, width
, height
and src
props to the Image Component.
@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to see unit tests!
@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
This pull request was successfully merged by @dhruvtailor7 in 47a05bc. When will my fix make it into a release? | Upcoming Releases |
…ht` and `src` props to the Image Component. (facebook#34481) Summary: This PR is for adding the support for `crossOrigin`, `referrerPolicy`, `width`, `height` and `srcSet` props to Image Component and mapping the `src` prop to `source.uri` of Image Component for the issue facebook#34424. An example is also added in the RNTester ImageExample. ## Changelog [General] [Changed] - Map the `src` prop to `source.uri` prop in Image Component. [General] [Added] - added `crossOrigin`, `referrerPolicy`, `width`, `height` and `srcSet` props to Image Component. Pull Request resolved: facebook#34481 Test Plan: 1. Navigate to Image Component Example in the RNTester app. 2. Contains an example of the Image component using the `src` and `srcSet` prop. 3. For headers, inspect the Image request using Flipper. <img src="https://user-images.githubusercontent.com/32268377/186153246-d7b72ce3-e082-46d9-87d1-aefacd3af34f.png" height="500" /> Reviewed By: christophpurrer Differential Revision: D38982041 Pulled By: cipolleschi fbshipit-source-id: dd6594e39b8f3b36cfcdafa35695254034f1fb7f
Summary: Fixes this: #41151 ## Changelog: [GENERAL] [FIXED] - Passed height and width as native props to support cases where source is an array. **Issue**: Unable to use height and width as props in Image components when passing source as an array. This functionality worked before this [commit](#34481). In Image.android.js and Image.ios.js, height and width props are extracted before passing them to the native side. This extraction makes these props ineffective when passed directly. Although setting height and width in style is a workaround, these props should still be respected since they exist for this purpose. The issue occurs only when the source prop is an array. When source is an object, width and height are manually passed to the style object, so the issue doesn't arise. Pull Request resolved: #47044 Test Plan: Tested this on `rn-tester` app Reviewed By: necolas, javache Differential Revision: D64458292 Pulled By: cipolleschi fbshipit-source-id: 5cacad79b8d4468a4a1fd0977221e42ce4b2e5d1
Summary
This PR is for adding the support for
crossOrigin
,referrerPolicy
,width
,height
andsrcSet
props to Image Component and mapping thesrc
prop tosource.uri
of Image Component for the issue #34424. An example is also added in the RNTester ImageExample.Changelog
[General] [Changed] - Map the
src
prop tosource.uri
prop in Image Component.[General] [Added] - added
crossOrigin
,referrerPolicy
,width
,height
andsrcSet
props to Image Component.Test Plan
src
andsrcSet
prop.