Skip to content

Commit f12a6fc

Browse files
refactoring
1 parent f48d4a1 commit f12a6fc

File tree

4 files changed

+10
-11
lines changed

4 files changed

+10
-11
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ powered by [Cloudimage](https://www.cloudimage.io/)
6161
* [Step 3: Implement](#implement)
6262
* [Configuration](#configuration)
6363
* [Image properties](#image_properties)
64-
* [Lazy loading](#lazy_loading)
6564
* [Browser support](#browser_support)
6665
* [Filerobot UI Family](#ui_family)
6766
* [Contributing](#contributing)
@@ -164,7 +163,7 @@ Applies a nice interlacing effect for preview transition
164163

165164
### filters
166165

167-
###### Type: **String** | Default: **'n'** | _optional_
166+
###### Type: **String** | Default: **'q35.foil1'** | _optional_
168167

169168
Applies default Cloudimage filters to your image, e.g. fcontrast, fpixelate, fgaussian, backtransparent,
170169
rotation... Multiple filters can be applied, separated by "```.```" (dot).

examples/src/index.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ import { darcula } from 'react-syntax-highlighter/dist/esm/styles/prism';
1212
const cloudimageConfig = {
1313
token: 'demo',
1414
baseUrl: 'https://cloudimage.public.airstore.io/demo/',
15-
filters: 'q80.foil1',
1615
queryString: '?&size_info=1&v=2',
17-
lazyLoadOffset: 100,
1816
placeholderBackground: '#e1e1e1'
1917
};
2018

@@ -409,8 +407,8 @@ render(<App />, document.body);`}</SyntaxHighlighter>
409407
<ul>
410408
<li><a target="_blank" href="https://github.com/scaleflex/js-cloudimage-responsive">JS Cloudimage Responsive</a></li>
411409
<li><a target="_blank" href="https://github.com/scaleflex/ng-cloudimage-responsive">Angular Cloudimage Responsive</a></li>
412-
<li><a target="_blank" href="https://github.com/scaleflex/filerobot-image-editor">Uploader</a></li>
413-
<li><a target="_blank" href="https://github.com/scaleflex/filerobot-uploader">Image Editor</a></li>
410+
<li><a target="_blank" href="https://github.com/scaleflex/filerobot-uploader">Uploader</a></li>
411+
<li><a target="_blank" href="https://github.com/scaleflex/filerobot-image-editor">Image Editor</a></li>
414412
</ul>
415413
</div>
416414
</div>

src/Provider.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class CloudimageProvider extends Component {
1919
width = '400',
2020
height = '300',
2121
operation = 'width',
22-
filters = 'n',
22+
filters = 'q35.foil1',
2323
placeholderBackground = '#f4f4f4',
2424
baseUrl = '/',
2525
presets,

src/index.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,14 @@ class Img extends Component {
107107

108108
const ratioBySize = getRatioBySize(this.state.size, config);
109109
const imageHeight = Math.floor(parentContainerWidth / (ratioBySize || ratio || 1));
110+
const resultRatio = (ratioBySize || ratio);
110111

111-
const pictureWithRatioStyles = (ratioBySize || ratio) ?
112+
const pictureWithRatioStyles = resultRatio ?
112113
{
113-
paddingBottom: (100 / (ratioBySize || ratio)) + '%',
114+
paddingBottom: (100 / resultRatio) + '%',
114115
background: (!isPreviewLoaded && !isLoaded) ? config.placeholderBackground : 'transparent'
115116
} : {};
116-
const imgWithRatioStyles = (ratioBySize || ratio) ? styles.imgWithRatio : {};
117+
const imgWithRatioStyles = resultRatio ? styles.imgWithRatio : {};
117118
const imgLoadingStyles = config.imgLoadingAnimation ?
118119
{ ...styles.imgWithEffect, filter: `blur(${Math.floor(parentContainerWidth / 100)}px)` } : {};
119120
const imgLoadedStyles = isLoaded && config.imgLoadingAnimation ? styles.imgLoaded : {};
@@ -133,7 +134,8 @@ class Img extends Component {
133134
...styles.img,
134135
...imgWithRatioStyles,
135136
...imgLoadingStyles,
136-
...imgLoadedStyles
137+
...imgLoadedStyles,
138+
...((isPreview && resultRatio) ? { height: '100%' } : {})
137139
}}
138140
src={!isPreview ? cloudimageUrl : (isPreviewLoaded ? cloudimageUrl : previewCloudimageUrl)}
139141
alt={alt}

0 commit comments

Comments
 (0)