-
-
Notifications
You must be signed in to change notification settings - Fork 591
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
imagesMaxWidth not working #412
Comments
@KimJeonghun91 Are you sure it's the RN version changes which cause a different behavior? We have proposed a new RFC for image and moreover media width here. There is a pending PR #389 ready to ship for v5.x. I could merge that to master and publish an alpha for you to test this. Are you interested? |
I am interested. |
BREAKING: imagesMaxWidth prop is discontinued in favor of contentWidth and computeImagesMaxWidth. See RFC001 for an exhaustive description. This patch offers a rewrite of the HTMLImage component to get a close match with RFC001, “a deterministic approach to images scaling”. The only part of this RFC which is unsupported is the unitConverter behavior, which is planned for a later major release. In addition to the capabilities defined in the RFC, this patch provides the following features and behaviors: - new property enableExperimentalPercentWidth. It allows percent width for <img> tags, computed relatively to contentWidth. - take margins into account when scaling down images; - support for overriding image styles, including resizeMode; - support for minWidth, minHeight, maxWidth, maxHeight styles. This patch also fixes #141, #172 and provides the features offered in PR #242 and #315. OPTIMIZATIONS: The imageBoxDimensions are computed when required. In addition, requirements are also recomputed when necessary, preventing expensive operations from happening too often. Also, because we need to flatten the style prop to infer requirements, this flatten value is now cached and re-evaluated when appropriate. Finally, styles have been moved to a stylesheet when that is possible, to avoid commiting updates to the native side. Note that these performance optimizations are made possible by the high coverage rate of the HTMLImage component. fixes #141 fixes #172 updates #412 (could fix) closes #315 closes #242
BREAKING: imagesMaxWidth prop is discontinued in favor of contentWidth and computeImagesMaxWidth. See RFC001 for an exhaustive description. This patch offers a rewrite of the HTMLImage component to get a close match with RFC001, “a deterministic approach to images scaling”. The only part of this RFC which is unsupported is the unitConverter behavior, which is planned for a later major release. In addition to the capabilities defined in the RFC, this patch provides the following features and behaviors: - new property enableExperimentalPercentWidth. It allows percent width for <img> tags, computed relatively to contentWidth. - take margins into account when scaling down images; - support for overriding image styles, including resizeMode; - support for minWidth, minHeight, maxWidth, maxHeight styles. This patch also fixes #141, #172 and provides the features offered in PR #242 and #315. OPTIMIZATIONS: The imageBoxDimensions are computed when required. In addition, requirements are also recomputed when necessary, preventing expensive operations from happening too often. Also, because we need to flatten the style prop to infer requirements, this flatten value is now cached and re-evaluated when appropriate. Finally, styles have been moved to a stylesheet when that is possible, to avoid commiting updates to the native side. Note that these performance optimizations are made possible by the high coverage rate of the HTMLImage component. fixes #141 fixes #172 updates #412 (could fix) closes #315 closes #242
@KimJeonghun91 I tried your code with the latest (alpha.2) and it works!
import * as React from 'react';
import {ScrollView, StyleSheet, useWindowDimensions} from 'react-native';
import HTML from 'react-native-render-html';
const html = `
<img id="se_object_1598178785239" src="https://blogfiles.pstatic.net/MjAyMDA4MjNfMjIy/MDAxNTk4MTc4Mzc0NzY3.lP4y6IgYLhsLj98qYypYb1TJCzHGHAArTBsjcafM5ckg.SyBbjTSKLfVT_Tve1bW55GsCgn4NZA74_ZqhxOPWPDYg.JPEG.0610studio/6-%ED%94%BD_01.jpg"
class="__se_object" s_type="attachment" s_subtype="photo"
style=" width:1080px; height:1084px; rwidth:1080px; rheight:1084px;" width="1080" height="1084" imgqe="true"
jsonvalue="%7B%7D" rwidth="1080px" rheight="1084px">
<img id="se_object_1598178852473" src="https://blogfiles.pstatic.net/MjAyMDA4MjNfMTE2/MDAxNTk4MTc4Mzc0OTkz.aTquUUjfOjIJHOIOQOmKl8EM5J2V8iks6Xjg2ngs7wEg.-qG--Ba8CK8u6LHxmUtn4ApJAyuZUiCykGUta2VRzykg.JPEG.0610studio/6-%ED%94%BD_02.jpg"
class="__se_object" s_type="attachment" s_subtype="photo"
style=" width:1080px; height:1076px; rwidth:1080px; rheight:1076px;" width="1080" height="1076" imgqe="true"
jsonvalue="%7B%7D" rwidth="1080px" rheight="1076px">
`;
export default function App() {
const {width} = useWindowDimensions();
return (
<ScrollView contentContainerStyle={styles.container}>
<HTML contentWidth={width} html={html} />
</ScrollView>
);
}
const styles = StyleSheet.create({
container: {
flexGrow: 1,
},
}); Notice that you don't need to set explicit width to your images anymore. The crucial step is to provide I'm closing now, but feel free to respond and / or add feedback. |
It does not work after changing the RN version from 0.60.3 to 0.63.2.
"react": "16.13.1",
"react-native": "0.63.2",
"react-native-render-html": "^4.2.3",
"react-native-webview": "^10.9.0"
The text was updated successfully, but these errors were encountered: