Bonjour,

Pour réaliser un rognage de photo, j'utilise jcrop.js.

Le code de la librairie a un bug particulièrement génant:
Sous chrome et safari (pas firefox) lorsqu'on reselectionne la photo que l'on a selectionné précédement, l'appel .Jcrop ne fonctionne pas.
Voici le code problématique

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Test jcrop</title>
<script type="text/javascript" src="jquery.js"></script>
<link rel="stylesheet" href="jquery.Jcrop.min.css" type="text/css" /><!-- http://jcrop-cdn.tapmodo.com/v0.9.12/css/jquery.Jcrop.min.css -->
<script src="jquery.Jcrop.min.js">//http://jcrop-cdn.tapmodo.com/v0.9.12/js/jquery.Jcrop.min.js</script>
</head>
 
<body>
<input type="hidden" name="MAX_FILE_SIZE" value="10485760" />
<input type="file" name="mon_fichier" accept="image/*"  style="visibility:visible;"/>

<input type="text" id="x1" name="X" />
<input type="text" id="y1" name="Y" />
<input type="text" id="w" name="Wi" />
<input type="text" id="h" name="He" />

<div id="cadrage_popup">
<div id="popup_rognage">
 <img id="jcrop_target" />
</div>
<div id="block_options" style="visibility:hidden;width:100%;height:140px;position:absolute;bottom:0;background:#000000;">
<div id="bouton_valider" style="visibility:hidden; cursor: pointer; position: absolute; bottom: 20px; right: 20px; width: 120px; height: 58px; border-top-left-radius: 10px; border-top-right-radius: 10px; border-bottom-right-radius: 10px; border-bottom-left-radius: 10px; background-color:rgb(69, 69, 69);"><div style="position:absolute;bottom:20px;cursor:pointer;width:120px;height:20px;color:#fff;font-family:ComicNeue-Regular;text-align:center;font-size:25px;font-family:MyriadPro-Regular;">VALIDER</div></div>
<div id="bouton_fermer" style="visibility:hidden; cursor: pointer; position: absolute; bottom: 20px; left: 20px; width: 120px; height: 58px; border-top-left-radius: 10px; border-top-right-radius: 10px; border-bottom-right-radius: 10px; border-bottom-left-radius: 10px; background-color:rgb(69, 69, 69);"><div style="position:absolute;bottom:20px;cursor:pointer;width:120px;height:20px;color:#fff;font-family:ComicNeue-Regular;text-align:center;font-size:25px;font-family:MyriadPro-Regular;">FERMER</div></div>
</div></div>

</body>
<script>

$('input[name=mon_fichier]').change(function(){
 $('#cadrage_popup').css({'visibility': 'visible','height':'100%','width':'100%','position':'absolute','background':'#000000'});
  $('#popup_rognage').css({'visibility': 'visible', 'width': '100%', 'height':'500px', 'position': 'relative','margin':'-250px 0 0 -250px','top':'50%','left':'50%','background':'#000000','overflow':'hidden'});
   $('#bouton_valider').css('visibility' , 'visible');
 $('#bouton_fermer').css('visibility' , 'visible');
 $('#block_options').css('visibility' , 'visible');
 readURL(this);
});



function readURL(input) { 
	if (input.files && input.files[0]) { 
		var reader = new FileReader(); 
		reader.onload = function (e) { 
		
			$('#jcrop_target').attr('src', e.target.result);
			
			
		}; 
		reader.readAsDataURL(input.files[0]);
		// modification des infos de taille et largeur lorsque l'image est loadée.
		$('#jcrop_target').on('load', function () {
			
			init_w = 500;
			init_h = 500;
			
			imgWidth = $('#jcrop_target').width();
			imgHeight = $('#jcrop_target').height();
			cle = imgWidth/imgHeight;
			

			if(cle > 1) {
				if(imgWidth > init_w) {w = init_w; h = init_w / cle; } 
				else if(imgHeight > init_h) {w = init_h * cle; h = init_h;}
			}// image plus large que haute
			if(cle < 1) {
				if(imgHeight > init_h) {h = init_h; w = init_h * cle; } 
				else if(imgWidth > init_w) {h = init_w / cle; w = init_w;}
			}// image plus haute que large
			if(cle == 1) { h = init_h ; w = init_h;}
			
			multi_w = imgWidth/w; multi_h = imgHeight/h;
			
			$('#jcrop_target').css({'height': h, 'width': w,'margin':'0px' });
			
			// destroy Jcrop if it is existed
			
            if (typeof jcrop_api != 'undefined') {
                jcrop_api.destroy();
	       }
			
			$('#jcrop_target').Jcrop({
			 		onSelect:    showCoords,
            		bgColor:     'black',
            		bgOpacity:   .4,
            		setSelect:   [ 0, 0, 100, 100 ],
           		 aspectRatio: 1 / 1
	
				}, function(){jcrop_api = this; alert(jcrop_api);});
			function showCoords(c) {
				X = c.x*multi_w;
				Y = c.y*multi_h;
				He = c.h*multi_h;
				Wi = c.w*multi_w;
				$("#x1").val(X);
				$("#y1").val(Y);
				$("#w").val(Wi);
				$("#h").val(He);
			}

			$("#bouton_fermer").on('click', function() {
				//alert('clique');
				$('#popup_rognage').css('visibility', 'hidden');
				$('#cadrage_popup').css('visibility', 'hidden');
				$('#block_options').css('visibility', 'hidden');
				$('#bouton_valider').css('visibility' , 'hidden');
				$('#bouton_fermer').css('visibility' , 'hidden');
				jcrop_api.destroy();
			   $('#jcrop_target').css('visibility' , 'hidden');
			});
			$("#bouton_valider").on('click', function() {
				$('#popup_rognage').css('visibility', 'hidden');
				$('#cadrage_popup').css('visibility', 'hidden');
				$('#block_options').css('visibility', 'hidden');
				$('#bouton_valider').css('visibility' , 'hidden');
				$('#bouton_fermer').css('visibility' , 'hidden');
				jcrop_api.destroy();
			   $('#jcrop_target').css('visibility' , 'hidden');
			  	marge_gauche = $("#x1").val();
				marge_haute  = $("#y1").val();
				carre = $("#w").val();
				lien = $('#jcrop_target').attr('src');
				$("#ajout_photo").children('div').children('img').css({'visibility':'visible', 'height': h, 'width': w, 'margin-left': -marge_gauche, 'margin-top': -marge_haute}).attr('src', lien);
			   
			});

/*OptionName 	Value 						Type 				Description 												Default

aspectRatio 	decimal 					Aspect 				ratio of w/h (e.g. 1 for square) 						n/a
minSize 		array 						[ w, h ] 			Minimum width/height, use 0 for unbounded dimension 	n/a
maxSize 		array 						[ w, h ] 			Maximum width/height, use 0 for unbounded dimension 	n/a
setSelect 		array 						[ x, y, x2, y2 ] 	Set an initial selection area 							n/a
bgColor 		color 						value 				Set color of background container 						'black'
bgOpacity 		decimal 					0 - 1 				Opacity of outer image when cropping 					.6 */

			
			
			
			
			
		});

	} 
}


</script>
</html>
Sur la console, il n'y a aucun message d'erreur

Merci d'avance