@@ -4,10 +4,10 @@ import { compute } from '../../mixins/compute';
44import { register } from ' ../../mixins/registerTransformation'
55import { computePlaceholder } from ' ../../helpers/computeOptions'
66import { getCldPlaceholder , isCldPlaceholder } from ' ../../helpers/findComponent'
7- import {
8- ACCESSIBILITY_TRANSFORMATIONS ,
9- PLACEHOLDER_TRANSFORMATIONS ,
10- COMPONENTS ,
7+ import {
8+ ACCESSIBILITY_TRANSFORMATIONS ,
9+ PLACEHOLDER_TRANSFORMATIONS ,
10+ COMPONENTS ,
1111 LAZY_LOADING ,
1212 IMAGE_CLASSES ,
1313 IMAGE_WITH_PLACEHOLDER_CSS ,
@@ -17,6 +17,7 @@ import {
1717} from ' ../../constants' ;
1818import { size } from " ../../mixins/size" ;
1919import { lazy } from " ../../mixins/lazy" ;
20+ import {getDevicePixelRatio } from ' ../../utils/getDevicePixelRatio' ;
2021
2122/**
2223 * Deliver images and specify image transformations using the cld-image (CldImage) component,
@@ -49,7 +50,7 @@ export default {
4950 },
5051 /**
5152 * **Deprecated**
52- *
53+ *
5354 * The placeholder image to use while the image is loading. Possible values:
5455 * - `"blur"` to use blur placeholder
5556 * - `"lqip"` to use a low quality image
@@ -92,14 +93,14 @@ export default {
9293 }
9394
9495 return (
95- < img
96+ < img
9697 attrs= {this .$attrs }
9798 src= {src}
9899 loading= {this .hasLazyLoading ? LAZY_LOADING : null }
99100 class = {imgClass}
100101 onload= {this .load }
101102 style= {style}
102- / >
103+ / >
103104 )
104105 },
105106 renderComp (children ) {
@@ -114,7 +115,13 @@ export default {
114115 const lazyModeInvisible = this .hasLazyLoading && ! this .visible
115116 const options = this .computeURLOptions ()
116117
117- const src = responsiveModeNoSize || lazyModeInvisible ? ' ' : this .cloudinary .url (this .publicId , this .toSnakeCase (options))
118+ let src = responsiveModeNoSize || lazyModeInvisible ? ' ' : this .cloudinary .url (this .publicId , this .toSnakeCase (options));
119+ // Update dpr_auto to dpr_1.0, 2.0 etc but only for responsive mode
120+ // This matches the behaviour in other SDKs
121+ if (this .responsive ) {
122+ src = src .replace (/ \b dpr_(1\. 0| auto)\b / g , ' dpr_' + getDevicePixelRatio (true ));
123+ }
124+
118125 const cldPlaceholder = getCldPlaceholder (children)
119126 const cldPlaceholderType = cldPlaceholder ? (cldPlaceholder .componentOptions ? .propsData ? .type || ' blur' ) : ' '
120127 const placeholderType = cldPlaceholderType || this .placeholder
@@ -159,6 +166,6 @@ export default {
159166 }
160167
161168 return this .renderComp (children)
162- }
169+ }
163170};
164171< / script>
0 commit comments