Git Product home page Git Product logo

cloudinary-api's Introduction

Cloudinary tree-shakable API

A set of lighter packages for using Cloudinary

cloudinary-build-url

npm version npm downloads Codecov License

Build URL for images and videos based on configurations.

📖  Documentation

💻  Codebase

✊  Coding coverage status

import { buildUrl } from 'cloudinary-build-url'

const src = buildUrl('example', {
  cloud: {
    cloudName: 'demo',
  },
  transformations: {
    resize: {
      type: 'scale',
      width: 500,
      height: 500,
      aspectRatio: "16:9"
    }
  }
})

console.log(src)

Installation

To use cloudinary-build-url:

npm i cloudinary-build-url

#OR
yarn add cloudinary-build-url

Use with TypeScript

cloudinary-build-url supports TypeScript. In order to start using the lib with TypeScript, please install @cld-apis/types as devDependencies.

npm i -D @cld-apis/types

#OR

yarn add -D @cld-apis/types

Supporting packages

@cld-apis/utils

Constants for transformations used in Cloudinary APIs, and other helper functionalities.

@cld-apis/types

Defined types used in cloudinary-build-url for TypeScript

Vue-cli plugin - vue-cli-plugin-cloudinary-api

Cloudinary API plugin for Vue-cli created projects

Maintained by Maya Shavin

cloudinary-api's People

Contributors

adi518 avatar andrewli-ca avatar apalumbo avatar chrillep avatar chunksnbits avatar colbyfayock avatar dependabot[bot] avatar kedarguy avatar mayashavin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

cloudinary-api's Issues

`getPathToAsset` replaces format from publicId (v0.2.1 cloudinary-build-url)

As per:
https://github.com/mayashavin/cloudinary-api/blob/main/packages/url/lib/url.ts#L98

The desired output for the following snippet should be
https://cdn-images.dum.dum/dummy-dum/image/upload/c_scale,w_500,h_500,q_eco,f_auto//image/vm/aedcb538-777e-4564-b422-30eb8dc220d2.png

setConfig({
  cloudName: 'dummy-dum',
  secureDistribution: 'cdn-images.dum.dum'
});

const url = buildUrl('/image/vm/aedcb538-777e-4564-b422-30eb8dc220d2.png', {
  cloud: {
    cloudName: 'dummy-dum',
  },
  transformations: {
    resize: {
      type: 'scale',
      width: 500,
      height: 500,
    },
    quality: "eco"
  }
})

Although, what I am receiving is
https://cdn-images.dum.dum/dummy-dum/image/upload/c_scale,w_500,h_500,q_eco,f_auto//image/vm/aedcb538-777e-4564-b422-30eb8dc220d2.
Notice the .png is removed.

Tried clearing dependency a few times. Has this change been published?

image

Hex colors not supported: E.g. #2A3E51

Hi @mayashavin

I am trying to add a custom color. On the url it would look like this: co_rgb:2A3E51. Using the Java SDK or other SDKs, it would understand that it's not a normal color and add the "_rgb" for me.

How do I do this with your plugin?

Thank you :-)

render URL for images inside folder

How can I get the URL for the images stored inside the folder?

This package is working for the images directly stored in Cloudinary, but it not working for those images which are stored in a folder. And this is obvious because I have given cloud name and image name only, but I am curious where can I enter my folder name?

import { buildUrl } from 'cloudinary-build-url'

  const blurURL2 = buildUrl('imageName', {
    cloud: {
      cloudName: 'cloudName'
    },
    transformations: {
      effect: 'blur:1000',
      quality: 1
    }
  })

buildUrl(): Duplicated, encoded quality/format?

Hi-

A usage of buildUrl such as:

const cloudinaryUrl = buildUrl('u/3dqed6rTAouJ1Gw3ojECe', {
    cloud: { cloudName:'uwhealth', },
});

Returns

https://res.cloudinary.com/uwhealth/image/upload/q_auto,f_auto/f_auto%2Cq_auto/v1/u/3dqed6rTAouJ1Gw3ojECe

Whereby an encoded f_auto%2Cq_auto is generated but seemingly is duplicated; if so, would be unnecessary.

Compatibility with Angular

Using this library in an Angular app results in the following errors:

Error: node_modules/cloudinary-build-url/dist/cjs/url.d.ts:1:104 - error TS2307: Cannot find module '@cld-apis/types' or its corresponding type declarations.
    
    1 import type { CloudConfig, TransformerOption, TransformerVideoOption, ResourceType, StorageType } from '@cld-apis/types';
                                                                                                             ~~~~~~~~~~~~~~~~~
    node_modules/cloudinary-build-url/dist/cjs/transformers/index.d.ts:1:37 - error TS2307: Cannot find module '@cld-apis/types' or its corresponding type declarations.
    
    1 import type { Transformation } from '@cld-apis/types';
                                          ~~~~~~~~~~~~~~~~~
    node_modules/cloudinary-build-url/dist/cjs/index.d.ts:1:46 - error TS2307: Cannot find module '@cld-apis/types' or its corresponding type declarations.
    
    1 import type { CldOptions, CloudConfig } from '@cld-apis/types';
                                                   ~~~~~~~~~~~~~~~~~
    node_modules/cloudinary-build-url/dist/cjs/index.d.ts:11:27 - error TS2307: Cannot find module '@cld-apis/types' or its corresponding type declarations.
    
    11     resourceType?: import("@cld-apis/types").ResourceType;
                                 ~~~~~~~~~~~~~~~~~
    node_modules/cloudinary-build-url/dist/cjs/index.d.ts:14:26 - error TS2307: Cannot find module '@cld-apis/types' or its corresponding type declarations.
    
    14     storageType?: import("@cld-apis/types").StorageType;
           

extractPublicId function returns an encoded public id

Hello,

I noticed a weird behaviour when using the extractPublicId function, let's say we upload a file named TestÀ.png, we would get an url like this, with the special character encoded:

https://res.cloudinary.com/XXXXXX/image/upload/photos/TestA%C3%8C_XXXXX.png

Now if I check the public id in cloudinary I have photos/TestAÌ_XXXXX while with the extractPublicId function I get photos/TestA%C3%8C_XXXXX, so it's still encoded and different from the correct one.

This is not a big deal since I can decode the public ID pretty easily after I get it, but I was asking myself if it makes sense to include the decoding directly into the extract function, or if there is any downside on doing that.

node_modules/@cld-apis/types/lib/index.d.ts:38:23 - error TS2307: Cannot find module './asset/Asset' or its corresponding type declarations.

Hi @mayashavin

Great library! Well done. Made my day as it's currently the only way of passing dynamic variables. cl-image doesn't support that yet.

I am trying to compile my Angular library that uses the buildImageUrl. It's failing during compilation:

✖ Compiling TypeScript sources through NGC
ERROR: node_modules/@cld-apis/types/lib/index.d.ts:38:23 - error TS2307: Cannot find module './asset/Asset' or its corresponding type declarations.

38 export { Asset } from './asset/Asset'
                         ~~~~~~~~~~~~~~~

An unhandled exception occurred: node_modules/@cld-apis/types/lib/index.d.ts:38:23 - error TS2307: Cannot find module './asset/Asset' or its corresponding type declarations.

38 export { Asset } from './asset/Asset'
                         ~~~~~~~~~~~~~~~

By looking in index.d.ts you can see that there is no asset directory nor an Asset class.

Invalid URL build for publicIds containing dot-char

Noted some odd bug with an image ID containing a dot (i.e., "."):

Sample image URL:

https://res.cloudinary.com/adacmkv/image/upload/f_auto,q_auto/v1608641937/ADAC%20Klassik/2021/Events/AEC/RS134993_RS129423_8.1_v7gpvg.jpg

Sample transformation:

buildUrl(encodePublicId, {
  transformations: {
    format: "auto",
    quality: "auto",
    resize: {
      width: 1024,
      height: 600,
      type: "fill",
    },
  },
});

Observed

  • The image url created is invalid (part ".1_v7gpvg" is replaced with "q_auto"

Custom filename when downloading a file from Cloudinary

Is there a way with cloudinary-api to return a custom filename when downloading the file?

With url params, there seems to be fl_attachment:custom-name something like: https://res.cloudinary.com/[cloud_name]/video/upload/fl_attachment:[new_filename]/[public_id].mp4

I'm wondering if this helper library supports this?

Add buildImageSrcSets

Input:

  • originalSize {width, height} : Size
  • publicId : string
  • transformations : TransformationOption

Output

  • src
  • srcSets : string[]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.