fix: [crawled screenshot] fix img error

pull/260/head
Terrtia 2018-09-18 16:58:49 +02:00
parent 5b31b6e853
commit 912f2352ab
No known key found for this signature in database
GPG Key ID: 1E1B1F50D84613D0
2 changed files with 18 additions and 16 deletions

View File

@ -166,16 +166,12 @@
ctx.webkitImageSmoothingEnabled = false;
ctx.imageSmoothingEnabled = false;
/// wait until image is actually available
img.onload = pixelate;
img.addEventListener("error", img_error);
var draw_img = false;
img.onError = "img.onerror=null;img.src='{{ url_for('static', filename='image/AIL.png') }}';"
/// some image, we are not struck with CORS restrictions as we
/// do not use pixel buffer to pixelate, so any image will do
img.src = "{{ url_for('showsavedpastes.screenshot', filename=screenshot) }}";
/// MAIN function
function pixelate() {
/// use slider value
@ -195,14 +191,19 @@
/// draw original image to the scaled size
ctx.drawImage(img, 0, 0, w, h);
/// then draw that scaled image thumb back to fill canvas
/// As smoothing is off the result will be pixelated
/// pixelated
ctx.drawImage(canvas, 0, 0, w, h, 0, 0, canvas.width, canvas.height);
}
/// event listeneners for slider and button
blocks.addEventListener('change', pixelate, false);
function img_error() {
img.onerror=null;
img.src="{{ url_for('static', filename='image/AIL.png') }}";
blocks.value = 50;
pixelate;
}
</script>
</body>

View File

@ -596,16 +596,12 @@ var ctx = canvas.getContext('2d'), img = new Image();
ctx.webkitImageSmoothingEnabled = false;
ctx.imageSmoothingEnabled = false;
/// wait until image is actually available
img.onload = pixelate;
img.addEventListener("error", img_error);
var draw_img = false;
img.onError = "img.onerror=null;img.src='{{ url_for('static', filename='image/AIL.png') }}';"
/// some image, we are not struck with CORS restrictions as we
/// do not use pixel buffer to pixelate, so any image will do
img.src = "{{ url_for('showsavedpastes.screenshot', filename=crawler_metadata['screenshot']) }}";
/// MAIN function
function pixelate() {
/// use slider value
@ -625,13 +621,18 @@ function pixelate() {
/// draw original image to the scaled size
ctx.drawImage(img, 0, 0, w, h);
/// then draw that scaled image thumb back to fill canvas
/// As smoothing is off the result will be pixelated
/// pixelated
ctx.drawImage(canvas, 0, 0, w, h, 0, 0, canvas.width, canvas.height);
}
/// event listeneners for slider and button
function img_error() {
img.onerror=null;
img.src="{{ url_for('static', filename='image/AIL.png') }}";
blocks.value = 50;
pixelate;
}
blocks.addEventListener('change', pixelate, false);
</script>