Skip to content
This repository was archived by the owner on Feb 23, 2023. It is now read-only.

Commit 05a449a

Browse files
committed
Info about srcset, iframe sizing
1 parent 5034f92 commit 05a449a

File tree

1 file changed

+54
-5
lines changed

1 file changed

+54
-5
lines changed

docs/index.html

Lines changed: 54 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,18 @@ <h3 id="images">Images</h3>
457457
<a href="http://codepen.io/fancyapps/pen/wgBrXd?editors=1000" target="_blank">View demo on CodePen</a>
458458
</p>
459459

460+
<p>
461+
fancyBox supports "scrset" so I can display different images based on viewport width. You can use this to improve download times for mobile users and over time save bandwidth.
462+
Example:
463+
</p>
464+
465+
<pre><code>&lt;a href=&quot;medium.jpg&quot; data-fancybox=&quot;images&quot; data-srcset=&quot;large.jpg 1600w, medium.jpg 1200w, small.jpg 640w&quot;&gt;
466+
&lt;img src=&quot;thumbnail.jpg&quot; /&gt;
467+
&lt;/a&gt;</code></pre>
468+
<p class="demo">
469+
<a href="https://codepen.io/fancyapps/pen/bqbpbO?editors=1000" target="_blank">View demo on CodePen</a>
470+
</p>
471+
460472
<p>
461473
It is also possible to protect images from downloading by right-click.
462474
While this does not protect from truly determined users, it should discourage the vast majority from ripping off your files.
@@ -471,6 +483,7 @@ <h3 id="images">Images</h3>
471483
<a href="http://codepen.io/fancyapps/pen/RKKqLx?editors=1010" target="_blank">View demo on CodePen</a>
472484
</p>
473485

486+
474487
<h3 id="inline">Inline</h3>
475488

476489
<p>
@@ -539,7 +552,7 @@ <h3 id="iframe">Iframe</h3>
539552

540553

541554
<p>
542-
<b>Tip</b>: To control fancyBox in parent window from inside an iframe:
555+
To access and control fancyBox in parent window from inside an iframe:
543556
</p>
544557

545558
<pre><code>// Adjust iframe height according to the contents
@@ -549,6 +562,38 @@ <h3 id="iframe">Iframe</h3>
549562
parent.jQuery.fancybox.getInstance().close();</code></pre>
550563

551564

565+
<p>
566+
Iframe dimensions can be controlled by CSS:
567+
</p>
568+
569+
<pre><code>.fancybox-slide--iframe .fancybox-content {
570+
width : 800px;
571+
height : 600px;
572+
max-width : 80%;
573+
max-height : 80%;
574+
margin: 0;
575+
}</code></pre>
576+
577+
578+
<p>
579+
These CSS rules can be overridden by JS, if needed:
580+
</p>
581+
582+
<pre><code>$(&quot;[data-fancybox]&quot;).fancybox({
583+
iframe : {
584+
css : {
585+
width : '600px'
586+
}
587+
}
588+
});</code></pre>
589+
590+
591+
<p>
592+
If you have not disabled iframe preloading (using an "preload" option), then the script will atempt to
593+
calculate content dimensions and will adjust width/height of iframe to fit with content in it.
594+
Keep in mind, that due to <a href="https://en.wikipedia.org/wiki/Same-origin_policy" target="_blank">same origin policy</a>,
595+
there are some limitations.
596+
</p>
552597

553598
<!--
554599
@@ -599,8 +644,12 @@ <h3>Video dimensions</h3>
599644

600645
<p>
601646
Obviously, you can choose any size you like, any combination with <code>min</code>/<code>max</code> values.
647+
<br />
648+
Aspect ratio lock for videos is not implemented yet, but if you wish, <a href="http://codepen.io/fancyapps/pen/dNzaQq?editors=1010" target="_blank">you can use this snippet</a>.
602649
</p>
603650

651+
652+
604653
<h3>Video parameters</h3>
605654

606655
<p>
@@ -1191,13 +1240,13 @@ <h3>How to customize caption</h3>
11911240

11921241

11931242
<p>
1194-
Example of using different source for caption:
1243+
Inside <code>caption</code> method, <code>this</code> refers to the clicked element. Example of using different source for caption:
11951244
</p>
11961245

11971246
<pre><code>$( '[data-fancybox]' ).fancybox({
1198-
caption : function( instance, item ) {
1199-
return $(this).find('figcaption').html();
1200-
}
1247+
caption : function( instance, item ) {
1248+
return $(this).find('figcaption').html();
1249+
}
12011250
});</code></pre>
12021251
<p class="demo">
12031252
<a href="https://codepen.io/fancyapps/pen/bgEQXo?editors=1010" target="_blank">View demo on CodePen</a>

0 commit comments

Comments
 (0)