PageSourceSearch

https://www.photogaspesie.ca/wp-content/plugins/ggt-composer-addon/assets/js/jquery.imageAspect.js?ver=1.5

js photogaspesie.ca collected 2026-10-02 04:05:28 UTC 2,123 bytes, 84 lines download raw bytes

1(function($){
2
3    "use strict";
4
5    /**
6     * Helper to convert IMG to resizable div
7     * @param $item
8     * @returns {*}
9     */
10
11    function maybeConvertImg($item){
12        var imgSrc = null,
13            $div = null;
14        if($item.prop("tagName") == "IMG"){
15            imgSrc = $item.attr("src");
16            $div = $("<div class=\"aspect-img-cover\"></div>");
17            $div.css({
18                "background-image": "url(" + imgSrc + ")",
19                "background-size": "cover",
20                "background-position": "center center"
21            });
22            $item.after($div);
23            $item.remove();
24            $item = $div;
25        }
26        return $item;
27    }
28
29    /**
30     * jQuery bridge
31     * @returns {$.fn}
32     */
33
34    $.fn.imageAspect = function(){
35
36        var $item = $(this),
37            aspect = $item.attr("data-img-aspect"),
38            aspectValues = null,
39            aspectX = null,
40            aspectY = null,
41            ratio,
42            $processedItem = $item,
43            onResize = function(){}
44            ;
45
46        function resetHeight(){
47            $processedItem.height($processedItem.width() / ratio);
48        }
49
50        aspectValues = aspect.split(":");
51
52        if(aspectValues[0]
53            && aspectValues[1]
54            && !isNaN(Number(aspectValues[0]))
55            && !isNaN(Number(aspectValues[1]))
56        ){
57            aspectX = Number(aspectValues[0]);
58            aspectY = Number(aspectValues[1]);
59
60            ratio = aspectX / aspectY;
61
62            $item.css({
63                "width": "100%",
64                "min-width": "100%"
65            });
66            $processedItem = maybeConvertImg($item);
67
68            onResize = jQuery.fn.debounce && typeof jQuery.fn.debounce === 'function'
69                ? $.debounce(100, false, resetHeight)
70                : resetHeight
71            ;
72            $(window).on("resize", onResize);
73            onResize();
74        }
75        return this;
76    };
77
78    $(document).ready(function(){
79        $("[data-img-aspect]").each(function(){
80            $(this).imageAspect();
81        })
82    });
83
84})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.