Skip to content

Commit

Permalink
Fix TinyMCE image upload when STATIC_URL is not /static/
Browse files Browse the repository at this point in the history
  • Loading branch information
fallen committed May 14, 2022
1 parent 361bd1d commit b5293fb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions pytition/petition/templates/layouts/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@
{% endblock %}
</div>

<script>
{% include 'petition/image_upload_url.js' %}
</script>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="{% static "vendor/jquery-3.3.1/jquery-3.3.1.min.js" %}"></script>
<script src="{% static "vendor/popper-1.14.6/popper.min.js" %}"></script>
Expand Down
3 changes: 3 additions & 0 deletions pytition/petition/templates/petition/image_upload_url.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function get_image_upload_url() {
return '{% url "image_upload" %}';
}
2 changes: 1 addition & 1 deletion pytition/pytition/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@
'image_upload_credentials': True,
'images_upload_handler': """function(blobInfo, success, failure) {
let xhr = new XMLHttpRequest();
xhr.open('POST', '/petition/image_upload');
xhr.open('POST', get_image_upload_url());
xhr.setRequestHeader('X-CSRFTOKEN', get_csrf_token()); // manually set header
xhr.onload = function() {
Expand Down

0 comments on commit b5293fb

Please sign in to comment.