0.0.20 • Published 3 years ago

gd-url-gen v0.0.20

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

Welcome

About this project

This project enables you to create Cloudinary URLs for your images and videos. Using this SDK, you can apply advanced transformations to your images and videos.

This SDK can also be used with popular frontend frameworks.

Help & Examples

Installation

npm install @cloudinary/url-gen 

Simple usage

// Import the Cloudinary class
import {Cloudinary} from '@cloudinary/url-gen';

// Create your instance
const cld = new Cloudinary({
    cloud: {
        cloudName: 'demo'
    },
    url: {
        secure: true // force https, set to false to force http
    }
});

// Let's create a new image
const myImage = cld.image('sample');
import {Resize} from '@cloudinary/url-gen/actions/resize';

myImage.resize(Resize.scale().width(100).height(100));

// When we're done, we can apply all our changes and create a URL.
const myURL = myImage.toURL();
console.log(myURL);
// https://res.cloudinary.com/demo/image/upload/c_scale,w_100,h_100/sample

More examples and documentation

Additional links

Transpilation

@cloudinary/url-gen is shipped as untranspiled ES6 code. @cloudinary/url-gen is optimized around bundle size, as such we do not transpile our distributed modules, we leave the decision of what browsers to support, and what transpilations to apply, to you, the user.

Testing with Jest

As mentioned above, we're shipping @cloudinary/url-gen with ES6 code, as this provides great tree-shaking potential. it also requires a few adjustments when testing.

In jest.config, you'll need to add these lines to allow babel to transpile our code.

{
  "transform": {
    "node_modules/@cloudinary/url-gen": "babel-jest"
  },
  "transformIgnorePatterns": ["/node_modules/(?!@cloudinary/url-gen)"]
}

Make sure to install babel-jest: npm install babel-jest

You'll also need to ensure you have a babel.config.js file (and not a .babelrc), and that it's configured properly to transpile code,

As an example:

module.exports = {
  "presets": [
    "@babel/preset-env"
  ]
};
0.0.20

3 years ago

0.0.16

3 years ago

0.0.17

3 years ago

0.0.18

3 years ago

0.0.19

3 years ago

0.0.15

3 years ago

0.0.14

3 years ago

0.0.10

3 years ago

0.0.11

3 years ago

0.0.12

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago