Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
?step=image_edit Caching
The cache prevention for images isn’t working in stock 4.9. I’m doing this in ebl_image_edit 3.0 and its a bit ugly to stop it from caching the image.
$('#fullsize-image .content-image').attr('id', 'mainImg');
// Reload image and append random query string to prevent caching. Its always a new image.
$(function() {
var $img = $('#mainImg');
if ($img.length) {
var newSrc = $img.attr('src').split('?')[0] + '?r=' + Math.random();
$img.attr('src', newSrc);
} else {
alert('<img id="mainImg"> not found');
}
});
and
// Include necessary JavaScript and CSS in the head section
public function ebl_image_edit_assets() {
// stop the god damn image caching
$out = '<meta charset="UTF-8">';
$out .= '<meta name="viewport" content="width=device-width, initial-scale=1.0">';
$out .= '<meta http-equiv="Cache-Control" content="no-store, no-cache, must-revalidate, max-age=0">';
$out .= '<meta http-equiv="Pragma" content="no-cache">';
$out .= '<meta http-equiv="Expires" content="0">';
// Include necessary JavaScript and CSS assets
$out .= '<script src="' . hu . 'textpattern/plugins/ebl-image-edit/jquery.Jcrop.js?v=' . time() . '"></script>';
$out .= '<link rel="stylesheet" href="' . hu . 'textpattern/plugins/ebl-image-edit/jquery.Jcrop.css?v=' . time() . '" type="text/css" />';
$out .= '<script src="' . hu . 'textpattern/plugins/ebl-image-edit/index.js?v=' . time() . '"></script>';
echo $out;
}
Last edited by TheEric (Today 05:07:40)
Offline
Pages: 1