@@ -256,16 +256,13 @@ public function cloudinary_url( $public_id = null, $args = array(), $size = arra
256256 'https:/ ' ,
257257 $ this ->url ( $ args ['resource_type ' ], $ asset_endpoint ),
258258 );
259-
260- if ( ! empty ( $ args ['transformation ' ] ) ) {
261- $ url_parts [] = self ::generate_transformation_string ( $ args ['transformation ' ], $ args ['resource_type ' ] );
262- }
263- $ base = pathinfo ( $ public_id );
259+ $ base = pathinfo ( $ public_id );
264260 // Only do dynamic naming and sizes if upload type.
265261 if ( 'image ' === $ args ['resource_type ' ] && 'upload ' === $ args ['delivery_type ' ] ) {
266262 $ new_path = $ base ['filename ' ] . '/ ' . $ base ['basename ' ];
267263 $ public_id = str_replace ( $ base ['basename ' ], $ new_path , $ public_id );
268264 }
265+
269266 // Add size.
270267 if ( ! empty ( $ size ) && is_array ( $ size ) ) {
271268 $ url_parts [] = self ::generate_transformation_string ( array ( $ size ), $ args ['resource_type ' ] );
@@ -274,6 +271,9 @@ public function cloudinary_url( $public_id = null, $args = array(), $size = arra
274271 $ public_id = str_replace ( $ base ['basename ' ], $ size ['file ' ], $ public_id );
275272 }
276273 }
274+ if ( ! empty ( $ args ['transformation ' ] ) ) {
275+ $ url_parts [] = self ::generate_transformation_string ( $ args ['transformation ' ], $ args ['resource_type ' ] );
276+ }
277277
278278 $ url_parts [] = $ args ['version ' ];
279279 $ url_parts [] = $ public_id ;
0 commit comments