Skip to content

Commit ee9fe48

Browse files
authored
Fix broken image editor (#378)
* Update image_editor.html.twig fix image editor in Pimcore 11 * Update image_editor.html.twig doc update
1 parent 9a7d88e commit ee9fe48

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

templates/admin/asset/image_editor.html.twig

+27-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,24 @@
7777

7878
<img style="visibility: hidden" id='image' src="{{ imageUrl }}" />
7979
<script {{ pimcore_csp.getNonceHtmlAttribute()|raw }}>
80-
window.addEventListener('load', function (e) {
80+
81+
/**
82+
* wait for image editor to be fully available
83+
* before loading image to editor
84+
*/
85+
async function loadEditor(e) {
86+
return new Promise(resolve => {
87+
var checkInterval = setInterval(() => {
88+
if (window.Layers) {
89+
clearInterval(checkInterval);
90+
loadImageToEditor(e);
91+
resolve(true);
92+
}
93+
}, 300);
94+
});
95+
}
96+
97+
function loadImageToEditor(e) {
8198
var image = document.getElementById('image');
8299
window.Layers.insert({
83100
name: "{{ asset.getFilename() }}",
@@ -109,7 +126,16 @@
109126
110127
return false;
111128
});
129+
}
130+
131+
window.addEventListener("load", function(e) {
132+
loadEditor(e).then(function() {
133+
console.log("editor loaded");
134+
});
112135
}, false);
136+
137+
138+
113139
</script>
114140

115141
</body>

0 commit comments

Comments
 (0)