@@ -53,6 +53,20 @@ class CloudinaryComponent extends PureComponent {
5353 return this . context || { } ;
5454 }
5555
56+ /**
57+ * React function: Called when this element is in view
58+ */
59+ onIntersect = ( ) => {
60+ this . setState ( { isInView : true } )
61+ }
62+
63+ getChildPlaceholder ( children ) {
64+ if ( children ) {
65+ return React . Children . toArray ( children )
66+ . find ( child => isCloudinaryComponent ( child , "CloudinaryPlaceholder" ) ) ;
67+ }
68+ }
69+
5670 getChildTransformations ( children ) {
5771 let result = children ? React . Children . toArray ( children )
5872 . filter ( child => isCloudinaryComponent ( child , "CloudinaryTransformation" ) )
@@ -76,13 +90,19 @@ class CloudinaryComponent extends PureComponent {
7690 * @protected
7791 */
7892 getTransformation ( extendedProps ) {
79- let { children, ...rest } = extendedProps ;
93+ let { children, accessibility , placeholder , ...rest } = extendedProps ;
8094 let ownTransformation = only ( Util . withCamelCaseKeys ( rest ) , Transformation . methods ) || { } ;
8195 let childrenOptions = this . getChildTransformations ( children ) ;
8296 if ( ! Util . isEmpty ( childrenOptions ) ) {
8397 ownTransformation . transformation = childrenOptions ;
8498 }
8599
100+ //Append placeholder and accessibility if exists
101+ const advancedTransformations = { accessibility, placeholder} ;
102+ Object . keys ( advancedTransformations ) . filter ( k => advancedTransformations [ k ] ) . map ( k => {
103+ ownTransformation [ k ] = advancedTransformations [ k ] ;
104+ } ) ;
105+
86106 return ownTransformation ;
87107 }
88108
@@ -106,14 +126,23 @@ class CloudinaryComponent extends PureComponent {
106126 , { } ) ;
107127 }
108128
129+ /**
130+ * Generated a configured Cloudinary object.
131+ * @param extendedProps React props combined with custom Cloudinary configuration options
132+ * @return {Cloudinary } configured using extendedProps
133+ */
134+ getConfiguredCloudinary ( extendedProps ) {
135+ const options = Util . extractUrlParams ( Util . withSnakeCaseKeys ( extendedProps ) ) ;
136+ return Cloudinary . new ( options ) ;
137+ }
138+
109139 /**
110140 * Generate a Cloudinary resource URL based on the options provided and child Transformation elements
111141 * @param extendedProps React props combined with custom Cloudinary configuration options
112142 * @returns {string } a cloudinary URL
113143 * @protected
114144 */
115145 getUrl ( extendedProps ) {
116-
117146 const { publicId} = extendedProps ;
118147 const cl = getConfiguredCloudinary ( extendedProps ) ;
119148 return cl . url ( publicId , this . getTransformation ( extendedProps ) ) ;
0 commit comments