Skip to content

Commit b5293fb

Browse files
committed
Fix TinyMCE image upload when STATIC_URL is not /static/
1 parent 361bd1d commit b5293fb

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

pytition/petition/templates/layouts/base.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@
5656
{% endblock %}
5757
</div>
5858

59+
<script>
60+
{% include 'petition/image_upload_url.js' %}
61+
</script>
5962
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
6063
<script src="{% static "vendor/jquery-3.3.1/jquery-3.3.1.min.js" %}"></script>
6164
<script src="{% static "vendor/popper-1.14.6/popper.min.js" %}"></script>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
function get_image_upload_url() {
2+
return '{% url "image_upload" %}';
3+
}

pytition/pytition/settings/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@
172172
'image_upload_credentials': True,
173173
'images_upload_handler': """function(blobInfo, success, failure) {
174174
let xhr = new XMLHttpRequest();
175-
xhr.open('POST', '/petition/image_upload');
175+
xhr.open('POST', get_image_upload_url());
176176
xhr.setRequestHeader('X-CSRFTOKEN', get_csrf_token()); // manually set header
177177
178178
xhr.onload = function() {

0 commit comments

Comments
 (0)