Hello,
The short answer would be, well, unfortunately no. This plugin is not that sophisticated, at least not yet. It was intended to move the functionality of conditional tags to the hands of content authors, not just developers.
And now for the long one:
At first I thought I could advise you to extend this plugin by writing your own and implementing your custom condition. But, apart from the fact that it would still be a very limited workaround for your situation, if you are comfortable with coding you could very well roll your own shortcode. Something like:
[remote_image src="https://remote.com/image.jpg" cached="https://local.com/cached_image.jpg"]
This would be achieved by making a new plugin like so:
<?php
/*
Plugin Name: Remote Image Shortcode
*/
add_shortcode('remote_image','remote_image_shortcode');
function remote_image_shortcode($atts)
{
$atts=shortcode_atts(
array(
'src'=>null,
'cached'=>plugins_url('no-image-available.jpg',__FILE__),
),
$atts,
'remote_image'
);
if(!$atts['src']) return '';
wp_enqueue_script('remote-image',plugins_url('remote-image.js',__FILE__),array('jquery'));
return "<img src='{$atts['src']}' data-cached='{$atts['cached']}'>";
}
And, of course, apart from your own (global fallback) no-image-available.jpg
, you would need a remote-image.js
in the same directory, which would look like the following:
(function($) {
$(document).ready(function () {
$('img[data-cached]')
.error(function() {
$(this).attr('src',$(this).attr('data-cached'));
});
});
})(jQuery);
You will notice that the availability of the remote image is not checked server-side, because we are only interested if the image was eventually downloaded by the browser or not. Hence the javascript.
HTH!