{"id":16347440,"url":"https://github.com/cuth/media-query-images","last_synced_at":"2025-11-09T04:30:27.524Z","repository":{"id":10712214,"uuid":"12960215","full_name":"cuth/media-query-images","owner":"cuth","description":"Change image src or background image path based on media queries","archived":false,"fork":false,"pushed_at":"2014-07-10T15:59:25.000Z","size":480,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-28T06:20:24.139Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cuth.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-09-19T21:49:29.000Z","updated_at":"2015-08-27T21:28:42.000Z","dependencies_parsed_at":"2022-09-02T06:10:45.663Z","dependency_job_id":null,"html_url":"https://github.com/cuth/media-query-images","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cuth%2Fmedia-query-images","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cuth%2Fmedia-query-images/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cuth%2Fmedia-query-images/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cuth%2Fmedia-query-images/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cuth","download_url":"https://codeload.github.com/cuth/media-query-images/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239566149,"owners_count":19660273,"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-10-11T00:42:27.523Z","updated_at":"2025-11-09T04:30:27.480Z","avatar_url":"https://github.com/cuth.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Media Query Images\n==================\n\nUse media queries to assign images from paths in attributes. This requires jQuery. Assign in javascript the attributes that will be used for each media query.\n\n```js\nnew MediaQueryImages('.selector', [\n    {\n        mediaQuery: '(max-width: 500px)',\n        attrName: 'data-src-small'\n    },\n    {\n        mediaQuery: '(max-width: 700px)',\n        attrName: 'data-src-medium'\n    },\n    {\n        attrName: 'data-src-large'\n    }\n], {\n    blankClass: 'hidden' // The class applied to the element if the image is blank.\n});\n```\n\nPublic Methods\n--------------\nCall `runCheck` to manually process the elements (this won't be necessary in normal situations).\n\nCall `refresh` to have MediaQueryImages rerun the selector if possible to check if images have been added or removed.\n\nHelpful CSS\n-----------\nHide image elements before src is applied.\n```css\nimg {\n    visibility: hidden;\n}\nimg[src] {\n    visibility: visible;\n}\n.hidden {\n    display: none;\n}\n```\n\njQuery Plugin\n-------------\nFor extra convenience use this as a jQuery plugin. The plugin method returns a MediaQueryImages instance rather than a jQuery object (chaining is not supported).\n```js\nvar profile = $('.selector').MediaQueryImages([{\n    mediaQuery: '(min-width: 750px)',\n    attrName: 'data-image'\n}]);\nprofile.refresh();\n```\n\nPolyfills\n---------\nFor older browser compatibility, polyfills for matchMedia, Array.prototype.forEach, Array.prototype.filter, Array.prototype.map, Function.prototype.bind might be necessary.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcuth%2Fmedia-query-images","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcuth%2Fmedia-query-images","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcuth%2Fmedia-query-images/lists"}