{"id":13808653,"url":"https://github.com/scaleflex/ng-cloudimage-responsive","last_synced_at":"2025-04-11T15:05:37.608Z","repository":{"id":33970688,"uuid":"164561032","full_name":"scaleflex/ng-cloudimage-responsive","owner":"scaleflex","description":"Cloudimage responsive plugin will make your website load the exact image size you need depending on your user's screen size. Multiple pixel ratios are supported. Any questions or issues, please report to https://github.com/scaleflex/ng-cloudimage-responsive/issues","archived":false,"fork":false,"pushed_at":"2023-10-19T08:01:57.000Z","size":1764,"stargazers_count":16,"open_issues_count":5,"forks_count":6,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-03-25T11:11:29.530Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/scaleflex.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2019-01-08T04:30:49.000Z","updated_at":"2024-05-22T17:45:10.000Z","dependencies_parsed_at":"2023-11-10T12:31:32.843Z","dependency_job_id":null,"html_url":"https://github.com/scaleflex/ng-cloudimage-responsive","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scaleflex%2Fng-cloudimage-responsive","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scaleflex%2Fng-cloudimage-responsive/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scaleflex%2Fng-cloudimage-responsive/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scaleflex%2Fng-cloudimage-responsive/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/scaleflex","download_url":"https://codeload.github.com/scaleflex/ng-cloudimage-responsive/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248281375,"owners_count":21077423,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-04T01:01:48.181Z","updated_at":"2025-04-11T15:05:37.585Z","avatar_url":"https://github.com/scaleflex.png","language":"TypeScript","readme":"[![Release](https://img.shields.io/github/v/release/scaleflex/js-cloudimage-responsive)](https://github.com/scaleflex/ng-cloudimage-responsive/releases)\n[![Free plan](https://img.shields.io/badge/price-includes%20free%20plan-green.svg)](https://www.cloudimage.io/en/home#b38181a6-b9c8-4015-9742-7b1a1ad382d5)\n[![Contributions welcome](https://img.shields.io/badge/contributions-welcome-orange.svg)](#contributing)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)\n[![Scaleflex team](https://img.shields.io/badge/%3C%2F%3E%20with%20%E2%99%A5%20by-the%20Scaleflex%20team-6986fa.svg)](https://www.scaleflex.com/en/home)\n[![Cloudimage](https://img.shields.io/badge/Powered%20by-cloudimage-blue)](https://www.cloudimage.io/en/home)\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://www.cloudimage.io/#gh-light-mode-only\"\u003e\n\t\t\u003cimg\n\t\t\talt=\"The Lounge\"\n\t\t\tsrc=\"https://scaleflex.cloudimg.io/v7/cloudimage.io/LOGO+WITH+SCALEFLEX-01.png?vh=f6080d\u0026w=350\"\u003e\n\t\u003c/a\u003e\n\u003c/p\u003e\n\n\u003ch1 align=\"center\"\u003e\n   Angular Cloudimage Responsive\n\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n\t\u003cstrong\u003e\n\t\t\u003ca href=\"#table_of_contents\"\u003eDocs\u003c/a\u003e\n\t\t•\n    \u003ca href=\"https://github.com/scaleflex/ng-cloudimage-responsive/blob/master/README_v6.md\" target=\"_blank\"\u003eDocumentation for v2 | Cloudimage v6\u003c/a\u003e\n\t\t•\n\t\t\u003ca href=\"https://scaleflex.github.io/ng-cloudimage-responsive/\" target=\"_blank\"\u003eDemo\u003c/a\u003e\n\t\t•\n\t\t\u003ca href=\"https://codesandbox.io/s/ng-cloudimage-responsive-v3-rtn0vd?file=/src/app/app.module.ts\" target=\"_blank\"\u003eCode Sandbox\u003c/a\u003e\n\t\t•\n\t\t\u003ca href=\"https://medium.com/@dmitry_82269/responsive-images-in-2019-now-easier-than-ever-b76e5a43c074\" target=\"_blank\"\u003eWhy?\u003c/a\u003e\n\t\u003c/strong\u003e\n\u003c/p\u003e\n\nThis plugin detects the width of any image container as well as the device pixel ratio\ndensity to load the optimal image size needed.\nImages are resized on-the-fly via the \u003ca href=\"https://cloudimage.io\" target=\"_blank\"\u003eCloudimage service\u003c/a\u003e, thus offering a comprehensive\nautomated image optimization service.\n\nWhen an image is first loaded on your website or mobile app,\nCloudimage's resizing servers will download the origin image from\nthe source, resize it for the client's screen size and deliver to your users through one or multiple\nContent Delivery Networks (CDNs). The generated image formats are cached in the CDN and will be delivered rocket fast on any subsequent request.\n\n**NOTE:** Your original (master) images should be stored on a server\nor storage bucket (S3, Google Cloud, Azure Blob...) reachable over\nHTTP or HTTPS by Cloudimage. If you want to upload your master images to\nCloudimage, contact us at\n[hello@cloudimage.io](mailto:hello@cloudimage.io).\n\n\u003cp align=\"center\"\u003e\n\t\u003cimg\n\t\talt=\"The Lounge\"\n\t\tsrc=\"https://demo.cloudimg.io/v7/https://cdn.scaleflex.it/filerobot/cloudimage-process.jpg?w=1400\"\u003e\n\u003c/p\u003e\n\n## Table of contents\n\n* [Demo](#demo)\n* [Compatibility](#compatibility)\n* [Requirements](#requirements)\n* [Step 1: Installation](#installation)\n* [Step 2: Initialize](#initialize)\n* [Step 3: Implement](#implement)\n* [Configuration](#configuration)\n* [Image properties](#image_properties)\n* [Lazy loading](#lazy_loading)\n* [Browser support](#browser_support)\n* [Filerobot UI Family](#ui_family)\n* [Contributing](#contributing)\n* [License](#license)\n\n\n## \u003ca name=\"demo\"\u003e\u003c/a\u003e Demo\n\nTo see the Cloudimage Responsive plugin in action, please check out the\n[Demo page](https://scaleflex.github.io/ng-cloudimage-responsive/).\nPlay with your browser's window size and observe your\nInspector's Network tab to see how Cloudimage delivers the optimal\nimage size to your browser, hence accelerating the overall page\nloading time.\n\n\n## \u003ca name=\"compatibility\"\u003e\u003c/a\u003e Compatibility\n| Version | Angular Version |\n|---------|--------------|\n| \u003e3.0.1   | \u003e=14.0.0 |\n| \u003c=3.0.1   | \u003c=13.x.x |\n\n## \u003ca name=\"requirements\"\u003e\u003c/a\u003e Requirements\n\nTo use the Cloudimage Responsive plugin, you will need a\nCloudimage token to deliver your images over CDN. Don't worry, it only takes seconds to get one by\nregistering [here](https://www.cloudimage.io/en/register_page).\nOnce your token is created, you can configure it as described below.\nThis token allows you to use 25GB of image cache and 25GB of worldwide\nCDN traffic per month for free.\n\n## \u003ca name=\"installation\"\u003e\u003c/a\u003eStep 1: Installation\n\nusing npm\n\n```\n$ npm install --save ng-cloudimage-responsive\n```\n\n## \u003ca name=\"initialize\"\u003e\u003c/a\u003eStep 2: Initialize\n\nAfter installing the ng-cloudimage-responsive lib, simply initialize it with your **token** and the **baseUrl**\nof your image storage:\n\n```javascript\nimport { NgModule } from '@angular/core';\nimport { BrowserModule } from '@angular/platform-browser';\nimport { CIModule, CIConfig, CI_CONFIG } from 'ng-cloudimage-responsive';\nimport { AppComponent } from './app.component';\n\nconst ciConfig: Partial\u003cCIConfig\u003e = {\n  token: 'demo',\n  baseUrl: 'https://jolipage.scaleflex.it/'\n};\n\n@NgModule({\n  declarations: [ AppComponent ],\n  imports: [ BrowserModule, CIModule ],\n  providers: [\n    { provide: CI_CONFIG, useValue: ciConfig }\n  ],\n  bootstrap: [ AppComponent ]\n})\nexport class MyAppModule {}\n```\n\n## \u003ca name=\"implement\"\u003e\u003c/a\u003eStep 3: Implement it\n\nFinally, just use the ci-img component:\n\n```html\n\u003cci-img src=\"img.jpg\" alt=\"Demo image\" ratio=\"1.5\"\u003e\u003c/ci-img\u003e\n```\n\nNOTE: \"ratio\" is recommended to prevent page layout jumping. The parameter is used to calculate image height to hold\nthe image position while image is loading.\n\n\u003ca href=\"https://codesandbox.io/s/ng-cloudimage-responsive-v3-rtn0vd?file=/src/app/app.module.ts\"\u003e\u003cimg src=\"https://codesandbox.io/static/img/play-codesandbox.svg\" alt=\"edeit in codesandbox\"/\u003e\u003c/a\u003e\n\n## \u003ca name=\"configuration\"\u003e\u003c/a\u003e Config\n\n### token\n\n###### Type: **String** | Default: **\"demo\"** | _required_\n\nYour Cloudimage customer token.\n[Subscribe](https://www.cloudimage.io/en/register_page) for a\nCloudimage account to get one. The subscription takes less than a\nminute and is totally free.\n\n### customDomain\n\n###### Type: **String** | Default: **\"cloudimage.io\"** | _optional_\n\nIf you use a custom CNAME for your cloudimage integration, you can set it here.\n\nNote: this will disregard your token above as this should be built into the CNAME entry.\n\n### baseUrl\n\n###### Type: **String** | Default: **\"/\"** | _optional_\n\nYour image folder on server, this alows to shorten your origin image URLs.\n\n### apiVersion\n\n###### Type: **String** | Default: **\"v7\"** | _optional_\n\nAllow to use a specific version of API.\n\n- set a specific version of API\n\n```javascript\nconst token = {\n  token: \"demo\",\n  baseURL: \"https://cdn.scaleflex.it/demo/\",\n  apiVersion: \"v7\", // optional\n};\n```\n\n- disable API version\n\n```javascript\nconst token = {\n  token: \"demo\",\n  baseURL: \"https://cdn.scaleflex.it/demo/\",\n  apiVersion: null, // optional\n};\n```\n\n### lazyLoading\n\n###### Type: **Bool** | Default: **true** | _optional_\n\nOnly images close to the client's viewport will be loaded, hence accelerating the page loading time. The plugin uses\n[ng-lazyload-image](https://github.com/tjoskar/ng-lazyload-image) library to achieve it.\n\n### lazyLoadOffset\n\n###### Type: **Number** | Default: **100** | _required_\n\nPreload an image even if it's e.g. 100px below the viewport\n(user have to scroll 100px more to see this image)\n\nApplies a nice interlacing effect for preview transition\n\n### params\n\n###### Type: **String** | Default: **'org_if_sml=1'** | _optional_\n\nApplies default Cloudimage operations/ filters to your image, e.g. brightness, contrast, rotation...\nMultiple params can be applied, separated by \"`\u0026`\" e.g. wat_scale=35\u0026wat_gravity=northeast\u0026wat_pad=10\u0026grey=1\n\n```javascript\nparams: \"org_if_sml=1\u0026grey=1\";\n```\n\n#### alternative syntax: type: **Object**\n\n```javascript\nparams: {\n    org_if_sml: 1,\n    grey: 1\n}\n```\n\n[Full cloudimage v7 documentation here.](https://docs.cloudimage.io/go/cloudimage-documentation-v7/en/introduction)\n\n### placeholderBackground\n\n###### Type: **String** | Default: **'#f4f4f4'** | _optional_\n\nPlaceholder coloured background while the image is loading or use it to set your custom placeholder image or gif\n\nFor example\n\n```\nplaceholderBackground: \"url('https:/https://cdn.scaleflex.it/filerobot/red-loader.gif') 50% 50% no-repeat\"\n```\n\n### lowQualityPreview\n\n###### Type: **Object**\n\n- `lowQualityPreview.minImgWidth` number (default: 400) - minimum width of an image to load a low-quality preview image\n\nExample:\n\n```javascript\nlowQualityPreview: {\n  minImgWidth = 400;\n}\n```\n\n### presets\n\n###### Type: **Object**\n\nDefault:\n\n```javascript\nconst ciConfig = {\n  token: 'demo',\n  baseUrl: 'https://jolipage.scaleflex.it/',\n  ...\n  presets: {\n      xs: '(max-width: 575px)', // up to 575    PHONE\n      sm: '(min-width: 576px)', // 576 - 767    PHABLET\n      md: '(min-width: 768px)', // 768 - 991    TABLET\n      lg: '(min-width: 992px)', // 992 - 1199   SMALL_LAPTOP_SCREEN\n      xl: '(min-width: 1200px)' // from 1200    USUALSCREEN\n  }\n};\n```\n\nBreakpoints shortcuts to use in image size property, can be overridden.\n\n### limitFactor\n\n###### Type: **Number** | Default: **100** | _optional_\n\nRounds up the size of an image to the nearest limitFactor value.\n\nFor example:\n\n- for an image with width **358px** and limitFactor equal to **100**, the plugin will round up to 400px;\n- for an image with width **358px** and limitFactor equal to **5**, the plugin will round up to 360px.\n\n### devicePixelRatioList\n\n###### Type: **[Number,...]** | Default: **[1, 1.5, 2]** | _optional_\n\nList of supported device pixel ratios. If there is no need to support retina devices, you should set an empty array `devicePixelRatioList: []`.\n\n### delay\n\n###### Type: **Number** | _optional_\n\nDelay for processing an image after rendering component.\n\n**NOTE:** normally, the parameter is not needed but in some cases with integrating third-party libraries, it can fix wrong\ncalculation of image container.\n\n### ImageSizeAttributes\n\n###### Type: **String** | possible values: 'use', 'ignore', 'take-ratio' | Default: **'use'**\n\nIf width and height attributes are set:\n\n**use** - width \u0026 height attributes values will be used to calculate image size (according to user's DPR) and **ratio**.\n\n**take-ratio** - width \u0026 height attributes values will be used only to calculate **ratio**.\n\n**ignore** - width \u0026 height attributes will be ignored.\n\nIf width and height attributes are NOT set, image container size will be detected to calculate result image size (according to user's DPR)\n\n_Note_: If only width or height attributes is set, ratio is going to be taken from ci-ratio image attribute\n\n## \u003ca name=\"image_properties\"\u003e\u003c/a\u003e Image properties\n\n### src\n\n###### Type: **String** | Default: **undefined** | _required_\n\nOriginal image hosted on your web server. You can use absolute path or\nrelative to baseUrl in your config.\n\n**NOTES:**\n\nThe plugin uses a special algorithm to detect the width of image container and set the image size accordingly.\nThis is the recommended way of using the Cloudimage Responsive plugin.\n\n\n\n### doNotReplaceURL\n\n###### Type: **bool** | Default: **false**\n\nIf set to **true** the plugin will only add query params to the given source of image.\n\n### disableAnimation\n\n###### Type: **Boolean** | Default: **false** | _optional_\n\nIf set, the plugin will disable the animation for the Img and render only a single img tag.\n\n### width\n\n###### Type: **String** (e.g. 300px, 20vw) | Default: **undefined**\n\nIf set, the plugin will use width as fixed value and change only according to the device pixel ratio.\n\n### height\n\n###### Type: **String** (e.g. 300px, 20vh) | Default: **undefined**\n\nIf it's set, the plugin will use height as fixed value and change only according to the device pixel ratio.\n\n### params\n\n###### Type: **String** | Default: **undefined** | _optional_\n\nYou can apply any Cloudimage operations/filters to your image, like brightness, contrast, rotation, etc.\nMultiple parameters can be applied, separated by \"`\u0026`\" e.g. **wat_scale=35\u0026wat_gravity=northeast\u0026wat_pad=10\u0026grey=1**\n\n```javascript\nparams = \"gray=1\u0026bright=10\";\n```\n\n#### alternative syntax: type: **Object**\n\n```javascript\nparams={{\n    bright: 10,\n    grey: 1\n}}\n```\n\n[Full cloudimage v7 documentation here.](https://docs.cloudimage.io/go/cloudimage-documentation-v7/en/introduction)\n\n### sizes\n\n###### Type: **Object** | Default: **undefined**\n\n**{preset breakpoint (xs,sm, md,lg,xl) or media query + ' ' + image params}**:\n\n```html\n\u003cci-img \n  src=\"dino-reichmuth-1.jpg\" \n  operation=\"crop\" \n  sizes={{ \n    \"(max-width: 575px)\": { w: 400, h: 150 }, \n    \"(min-width): 576px)\": { r: 1 }, \n    \"(min-width: 620px)\": { h: 560 }, \n    \"(min-width: 768px)\": { w: \"50vw\" }, \n    \"(min-width: 992px)\": { w: \"55vw\", h: 300 }, \n    \"(min-width: 1200px)\": { w: 1200 }\n  }} \n/\u003e\n```\n\nYou can drop some breakpoints, for example:\n\n```html\n\u003cci-img \n  src=\"dino-reichmuth-1.jpg\" \n  operation=\"crop\"\n  sizes={{ \n    sm: { w: 400, h: 200 }, \n    \"(min-width: 620px)\": { w: 200, h: 60 }\n  }} \n/\u003e\n```\n\n##### new experimental syntax\n\nmd: { w: '40vw', h: 350 } or md: { w: 250, h: '20vh' }\n\nadds possibility to use fixed height or width and change dynamically other dimension\n\n**NOTE:** if size is not set, the plugin uses a special algorithm to\ndetect the width of image container and set the image size accordingly. This is the recommended way of using the Cloudimage Responsive plugin.\n\n### ratio\n\n###### Type: **Number** | _optional_\n\nIt is recommended to prevent page layout jumping. The parameter is used to calculate image height to hold\nthe image position while image is loading.\n\nTo see the full cloudimage documentation [click here](https://docs.cloudimage.io/go/cloudimage-documentation)\n\n### lazyLoading\n\n###### Type: **Bool** | Default: **undefined** | _optional_\n\nProperty allows to override global lazyLoading config for specific images.\n\n## \u003ca name=\"browser_support\"\u003e\u003c/a\u003eBrowser support\n\nTested in all modern browsers and IE 11.\n\n## \u003ca name=\"ui_family\"\u003e\u003c/a\u003eFilerobot UI Familiy\n\n* [JS Cloudimage Responsive](https://github.com/scaleflex/js-cloudimage-responsive)\n* [React Cloudimage Responsive](https://github.com/scaleflex/react-cloudimage-responsive)\n* [JS Cloudimage 360 view](https://github.com/scaleflex/js-cloudimage-360-view)\n* [Image Editor](https://github.com/scaleflex/filerobot-image-editor)\n* [Uploader](https://github.com/scaleflex/filerobot-uploader)\n\n## \u003ca name=\"contributing\"\u003e\u003c/a\u003eContributing!\n\nAll contributions are super welcome!\n\n\n## \u003ca name=\"license\"\u003e\u003c/a\u003eLicense\nAngular Cloudimage Responsive is provided under the [MIT License](https://opensource.org/licenses/MIT)\n","funding_links":[],"categories":["Table of contents"],"sub_categories":["Third Party Components"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscaleflex%2Fng-cloudimage-responsive","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscaleflex%2Fng-cloudimage-responsive","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscaleflex%2Fng-cloudimage-responsive/lists"}