snipt

Ctrl+h for KB shortcuts

Text only

CIRCLE IMAGE SIMPLE

1
2
3
4
5
6
7
.img-circle {
    border-radius: 50%;
}

Now any image with the img-circle class will be displayed as a perfect circle:

<img class="img-circle" src="kitten.jpg">
https://snipt.net/embed/14f7751b5d61be4d632534297219db3e/
https://snipt.net/raw/14f7751b5d61be4d632534297219db3e/
14f7751b5d61be4d632534297219db3e
text
Text only
7
2016-09-30T23:32:34
True
False
False
Sep 26, 2015 at 06:16 PM
/api/public/snipt/141251/
circle-image-simple
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a> <a href="#L-7">7</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a>.img-circle { </span><span id="L-2"><a name="L-2"></a> border-radius: 50%; </span><span id="L-3"><a name="L-3"></a>} </span><span id="L-4"><a name="L-4"></a> </span><span id="L-5"><a name="L-5"></a>Now any image with the img-circle class will be displayed as a perfect circle: </span><span id="L-6"><a name="L-6"></a> </span><span id="L-7"><a name="L-7"></a>&lt;img class=&quot;img-circle&quot; src=&quot;kitten.jpg&quot;&gt; </span></pre></div> </td></tr></table>
circle, css, image

CSS

Image set Color black white

1
2
3
4
5
#image{
	filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale"); 
	filter: gray; 
	-webkit-filter: grayscale(100%);
}
https://snipt.net/embed/aa4e5343ceb1745eac8007803dce64e6/
https://snipt.net/raw/aa4e5343ceb1745eac8007803dce64e6/
aa4e5343ceb1745eac8007803dce64e6
css
CSS
5
2016-10-01T00:49:12
True
False
True
Aug 21, 2014 at 04:46 AM
/api/public/snipt/136200/
image-set-color-black-white-0591ef6d
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="nf">#image</span><span class="p">{</span> </span><span id="L-2"><a name="L-2"></a> <span class="n">filter</span><span class="o">:</span> <span class="sx">url(&quot;data:image/svg+xml;utf8,&lt;svg xmlns=\&#39;http://www.w3.org/2000/svg\&#39;&gt;&lt;filter id=\&#39;grayscale\&#39;&gt;&lt;feColorMatrix type=\&#39;matrix\&#39; values=\&#39;0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\&#39;/&gt;&lt;/filter&gt;&lt;/svg&gt;#grayscale&quot;)</span><span class="p">;</span> </span><span id="L-3"><a name="L-3"></a> <span class="n">filter</span><span class="o">:</span> <span class="nb">gray</span><span class="p">;</span> </span><span id="L-4"><a name="L-4"></a> <span class="o">-</span><span class="n">webkit</span><span class="o">-</span><span class="n">filter</span><span class="o">:</span> <span class="n">grayscale</span><span class="p">(</span><span class="m">100%</span><span class="p">);</span> </span><span id="L-5"><a name="L-5"></a><span class="p">}</span> </span></pre></div> </td></tr></table>
css, image

JavaScript

Fancybox open from needed index

$.fancybox.open($('.fancybox'), {index: 0});
https://snipt.net/embed/4d744b9fa5a28fda34ebe36ec7df5f47/
https://snipt.net/raw/4d744b9fa5a28fda34ebe36ec7df5f47/
4d744b9fa5a28fda34ebe36ec7df5f47
js
JavaScript
1
2016-09-30T20:28:30
True
False
False
Mar 22, 2014 at 07:02 AM
/api/public/snipt/123027/
fancybox-open-from-needed-index
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="nx">$</span><span class="p">.</span><span class="nx">fancybox</span><span class="p">.</span><span class="nx">open</span><span class="p">(</span><span class="nx">$</span><span class="p">(</span><span class="s1">&#39;.fancybox&#39;</span><span class="p">),</span> <span class="p">{</span><span class="nx">index</span><span class="o">:</span> <span class="mi">0</span><span class="p">});</span> </span></pre></div> </td></tr></table>
box, fancy, fancybox, gallery, image, images, jquery, modal, plugin

JavaScript

Test if href points image

1
2
3
4
if($(this).attr('href').indexOf('.jpg') > 0) // or any other extension
{
    //do what you want
}
https://snipt.net/embed/6b6e76de0f8d48d7e980f025b5f0f153/
https://snipt.net/raw/6b6e76de0f8d48d7e980f025b5f0f153/
6b6e76de0f8d48d7e980f025b5f0f153
js
JavaScript
4
2016-10-01T02:33:41
True
False
False
Mar 17, 2014 at 01:11 PM
/api/public/snipt/122560/
test-if-href-points-image
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="k">if</span><span class="p">(</span><span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">attr</span><span class="p">(</span><span class="s1">&#39;href&#39;</span><span class="p">).</span><span class="nx">indexOf</span><span class="p">(</span><span class="s1">&#39;.jpg&#39;</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">)</span> <span class="c1">// or any other extension</span> </span><span id="L-2"><a name="L-2"></a><span class="p">{</span> </span><span id="L-3"><a name="L-3"></a> <span class="c1">//do what you want</span> </span><span id="L-4"><a name="L-4"></a><span class="p">}</span> </span></pre></div> </td></tr></table>
check, href, image, img, javascript, jpeg, jpg, jquery, js, test

JavaScript

WebP Image with Fallback

<img src="image.webp" onerror="this.onerror=null; this.src='image.png'">
https://snipt.net/embed/3129a92b49c67565ace361fb10dedc62/
https://snipt.net/raw/3129a92b49c67565ace361fb10dedc62/
3129a92b49c67565ace361fb10dedc62
js
JavaScript
1
2016-09-30T11:08:43
True
False
False
Apr 08, 2014 at 09:22 AM
/api/public/snipt/114585/
webp-image-with-fallback
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="o">&lt;</span><span class="nx">img</span> <span class="nx">src</span><span class="o">=</span><span class="s2">&quot;image.webp&quot;</span> <span class="nx">onerror</span><span class="o">=</span><span class="s2">&quot;this.onerror=null; this.src=&#39;image.png&#39;&quot;</span><span class="o">&gt;</span> </span></pre></div> </td></tr></table>
image, img, js, webp
Copyrighted, illegal, or inappropriate content? Email support@snipt.net.