{"id":18734321,"url":"https://github.com/threespot/object-fit-image","last_synced_at":"2025-07-11T07:06:15.249Z","repository":{"id":57140818,"uuid":"126769045","full_name":"Threespot/object-fit-image","owner":"Threespot","description":"“object-fit” polyfill for images","archived":false,"fork":false,"pushed_at":"2020-09-04T21:06:19.000Z","size":630,"stargazers_count":2,"open_issues_count":1,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-07-08T09:18:55.003Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/Threespot.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-03-26T03:33:56.000Z","updated_at":"2020-02-02T15:32:01.000Z","dependencies_parsed_at":"2022-09-01T23:51:20.413Z","dependency_job_id":null,"html_url":"https://github.com/Threespot/object-fit-image","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/Threespot/object-fit-image","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Threespot%2Fobject-fit-image","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Threespot%2Fobject-fit-image/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Threespot%2Fobject-fit-image/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Threespot%2Fobject-fit-image/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Threespot","download_url":"https://codeload.github.com/Threespot/object-fit-image/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Threespot%2Fobject-fit-image/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264753043,"owners_count":23658778,"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-11-07T15:13:00.233Z","updated_at":"2025-07-11T07:06:15.223Z","avatar_url":"https://github.com/Threespot.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `object-fit` Image Polyfill\n\n[![npm](https://badge.fury.io/js/%40threespot%2Fobject-fit-image.svg)](https://www.npmjs.com/package/@threespot/object-fit-image)\n[![Build Status](https://travis-ci.org/Threespot/object-fit-image.svg?branch=master)](https://travis-ci.org/Threespot/object-fit-image)\n[![Coverage Status](https://coveralls.io/repos/github/Threespot/object-fit-image/badge.svg)](https://coveralls.io/github/Threespot/object-fit-image)\n\nPolyfills `object-fit: cover` on `\u003cimg\u003e` or `\u003cpicture\u003e` tags by applying the `src` as an inline “background-image” on a target wrapper. Required for IE 11- and Android 4.4-. We recommend using [Picturefill](https://scottjehl.github.io/picturefill) to polyfill the `\u003cpicture\u003e` element itself.\n\n## Install\n\n```bash\nyarn add @threespot/object-fit-image\n```\n\n## Usage\n\n**Markup**\n```html\n  \u003cdiv class=\"bg-image\"\u003e\n    \u003cimg class=\"bg-image-source\" src=\"https://satyr.io/320x16:9\" srcset=\"https://satyr.io/320x16:9 320w, https://satyr.io/640x16:9 640w\" alt=\"Image description.\"\u003e\n  \u003c/div\u003e\n```\n\n```js\nimport ObjectFitImage from \"@threespot/object-fit-image\";\n\nvar imageWrappers = document.querySelectorAll(\".bg-image\");\n\nimageWrappers.forEach(el =\u003e new ObjectFitImage(el));\n\n// With custom options\nimageWrappers.forEach(el =\u003e new ObjectFitImage(el, {\n  visuallyHiddenClass: \"vh\",\n  backgroundPosition: \"50% 0\"\n}));\n```\n\nExample styles for browsers that support `object-fit`:\n\n```scss\n  .bg-image {\n    display: block;// for \u003cpicture\u003e elements\n    position: relative;\n\n    \u0026-source {\n      height: 100%;\n      left: 0;\n      object-fit: cover;\n      position: absolute;\n      top: 0;\n      width: 100%;\n    }\n  }\n```\n\n**Additional markup examples**\n```html\n  \u003c!-- Picture tag --\u003e\n  \u003cpicture class=\"bg-image\"\u003e\n    \u003csource srcset=\"https://satyr.io/768x16:9/3\" media=\"(min-width: 768px)\"\u003e\n    \u003csource srcset=\"https://satyr.io/480x16:9/2\" media=\"(min-width: 480px)\"\u003e\n    \u003cimg class=\"bg-image-source\" src=\"https://satyr.io/320x16:9/1\" alt=\"Image description 2 test.\"\u003e\n  \u003c/picture\u003e\n\n  \u003c!-- Picture tag with wrapper --\u003e\n  \u003cdiv class=\"bg-image\"\u003e\n    \u003cpicture class=\"bg-image-source\"\u003e\n      \u003csource srcset=\"https://satyr.io/768x16:9/3\" media=\"(min-width: 768px)\"\u003e\n      \u003csource srcset=\"https://satyr.io/480x16:9/2\" media=\"(min-width: 480px)\"\u003e\n      \u003cimg src=\"https://satyr.io/320x16:9/1\" alt=\"Image description 1 test.\"\u003e\n    \u003c/picture\u003e\n  \u003c/div\u003e\n```\n\n## License\n\nThis is free software and may be redistributed under the terms of the [MIT license](https://github.com/Threespot/object-fit-image/blob/master/LICENSE.md).\n\n## About Threespot\n\nThreespot is an independent digital agency hell-bent on helping those, and only those, who are committed to helping others. Find out more at [https://www.threespot.com](https://www.threespot.com).\n\n[![Threespot](https://avatars3.githubusercontent.com/u/370822?v=3\u0026s=100)](https://www.threespot.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthreespot%2Fobject-fit-image","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthreespot%2Fobject-fit-image","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthreespot%2Fobject-fit-image/lists"}