You need to be logged in to post in the forum - Log In

An active JCE Pro Subscription is required to post in the forum - Buy a Subscription

Support is currently Online

Official support hours
Monday to Friday
09:00 - 17:00 Europe/London (BST)

#104427 Loading latest jpg from a live cam / avoid loading from cache

Posted in ‘Mediabox’
This is a public ticket

Everybody will be able to see its contents. Do not include usernames, passwords or any other sensitive information.

Latest post by Ryan on Saturday, 30 May 2020 12:39 BST

woidl
Hi, I am using the popup for displaying a live-cam / weather cam. Unfortunately somehow older images (jpgs) are loaded - not the latest images. Not good for a "live" cam. Might be loaded from cache. Can I adapt the code to get always the latest jpg into the popup???

<a class="jcepopup noicon" style="color: #338c14;" href="https://d38553.ispservices.at/panoramabild_big.jpg" target="_blank" rel="noopener" data-mediabox="1" data-mediabox-width="1200" data-mediabox-height="800" data-mediabox-title="Live-Cam Golfpark">WETTERCAM</a>
thanks

Ryan
If you can add some javascript to your site, then add this:

jQuery(document).ready(function($) {
    WfMediabox.Plugin.add('image', function () {
        this.type = "image";

        // create image html (leave src blank)
        this.html = function (data) {
            
            // add time to the url to prevent caching...
            data.src += '?' + new Date().getTime();
            
            var $img = $('<img src="https://www.joomlacontenteditor.net/' + data.src + '" class="wf-mediabox-img" alt="' + decodeURIComponent(data.alt || data.title || "") + '" tabindex="0" />');

            if (data.params) {
                $.each(data.params, function (name, value) {
                    $img.attr(name, value);
                });
            }

            return $img;
        };

        this.is = function (data) {
            var src = data.src;
            // remove query to test extension
            src = src.split('?')[0];
            return /image\/?/.test(data.type) || /\.(jpg|jpeg|png|gif|bmp|tif|webp)$/i.test(src);
        };
    });
});

Ryan Demmer

Lead Developer / CEO / CTO

Just because you're not paranoid doesn't mean everybody isn't out to get you.

woidl
Hi,

Is there any other possible solution - without using this script? Causes trouble.

Ryan
Is there any other possible solution - without using this script? Causes trouble.


It shouldn't cause any problem if implemented correctly. What issue are you seeing?

Ryan Demmer

Lead Developer / CEO / CTO

Just because you're not paranoid doesn't mean everybody isn't out to get you.

woidl
I have put the script tinto the js file of the template as the template support told me.
The script seems to work, loads latest jpg - but it affects other modules.

1. the slideshow module does not show any images just white space.
2. the pop is no poup anymore, just a jpg in a blank new window.

I could live with #2, but #1 is bad.

Attachments

Ryan
Try this script instead:

jQuery(document).ready(function($) {
    $('.jcepopup').attr('href', function(i, val) {
    	if (/\.(jpeg|jpg|png)$/.test(val)) {
    		return val += '?' + new Date().getTime();
    	}
    });
});

Ryan Demmer

Lead Developer / CEO / CTO

Just because you're not paranoid doesn't mean everybody isn't out to get you.