Skip to content

Instantly share code, notes, and snippets.

View ashukasma's full-sized avatar
🎯
Focusing

Ashish ashukasma

🎯
Focusing
View GitHub Profile
@ashukasma
ashukasma / imgURL.js
Created August 25, 2016 13:19 — forked from DanWebb/imgURL.js
Specify a size for a Shopify image asset url. Equivalent to the liquid image size filter: `{{ image | img_url: "medium" }}`
String.prototype.imgURL = function(size) {
// remove any current image size then add the new image size
return this
.replace(/_(pico|icon|thumb|small|compact|medium|large|grande|original|1024x1024|2048x2048|master)+\./g, '.')
.replace(/\.jpg|\.png|\.gif|\.jpeg/g, function(match) {
return '_'+size+match;
})
;
};
@ashukasma
ashukasma / Image Size
Last active April 11, 2017 17:05 — forked from mnuno10/Change Image By Size
Shopify
<picture>
<source media="(max-width: 480px)" srcset="{{ home_slideshow_large_image | asset_url }} 1x, {{ 'slideshow_1_1024x1024.jpg' | asset_url }} 2x">
<source media="(max-width: 640px)" srcset="{{ home_slideshow_grande_image | asset_url }} 1x, {{ 'slideshow_1_1024x1024.jpg' | asset_url }} 2x">
<source media="(max-width: 1024px)" srcset="{{ home_slideshow_1024_image | asset_url }} 1x, {{ 'slideshow_1.jpg' | asset_url }} 2x">
<img src="{% comment %}ly_asset_replace_for_[ home_slideshow_image | asset_url ]_begin{% endcomment %}{% assign ly_asset = home_slideshow_image %}{% include 'ly-asset' with ly_asset %}{{ ly_translation }}{% comment %}ly_asset_replace_end{% endcomment %}" alt="">
</picture>
@ashukasma
ashukasma / gist:b5dabcd6d14117366174
Created March 20, 2016 01:10 — forked from dlindenkreuz/gist:a439ec4b939f0561d6d9
Shopify handleize function in JavaScript
// one-liner version
// retains latin-1 supplement chars as well as latin extended-a and latin extended-b
Shopify.handleize = function (str) {
return str.toLowerCase().replace(/[^\w\u00C0-\u024f]+/g, "-").replace(/^-+|-+$/g, "");
};
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Bootstrap Modals only - by shlomo hassid</title>
<script type='text/javascript' src='//code.jquery.com/jquery-1.11.0.js'></script>
<style type='text/css'>
[role="button"] {
cursor: pointer;
}