question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Pass original filename to images_upload_handler: TinyMCE

See original GitHub issue

I have this in set up,

tinymce.init({
selector: "textarea",
automatic_uploads: true,
images_reuse_filename: true,

images_upload_handler: function (blobInfo, success, failure) {
var xhr, formData;
xhr = new XMLHttpRequest();
xhr.withCredentials = false;
xhr.open('POST', '/cloud/tinymce/');

xhr.onload = function() {
  var json;

  if (xhr.status != 200) {
    failure('HTTP Error: ' + xhr.status);
    return;
  }

  json = JSON.parse(xhr.responseText);

  if (!json || typeof json.location != 'string') {
    failure('Invalid JSON: ' + xhr.responseText);
    return;
  }

  success(json.location);
};

formData = new FormData();
formData.append('file', blobInfo.blob(), blobInfo.filename());

xhr.send(formData);
},
});

When I upload an image, with name like cauliflower_chorizo.png, its renamed to blobid0.jpg https://s3-us-west-1.amazonaws.com/happyherbivoretest/2017/05/blobid0.jpg. Is there a way to upload the image with it’s original name cauliflower_chorizo.png?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:15 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
Afraithecommented, May 16, 2017

V4 tells us nothing, is it CDN/Cloud/SDK version? What 4.5.3? 4.1? 4.6? 4.6.1?

0reactions
trungtruc056commented, Jun 3, 2021

Hi @spocke, I’m using TinyMCE version 5.3.2 and I have the same issue with @alexkasina , it’s not fixed yet. Please check it. Thank you!

Update: The latest version still have this bug with using: images_upload_handler

Read more comments on GitHub >

github_iconTop Results From Across the Web

Image & file options | Docs - TinyMCE
By default TinyMCE will generate unique filename for each uploaded file (for details ... images_upload_url should pass along credentials (such as cookies, ...
Read more >
TinyMCE: Rename Image File Name Before Upload
What I want to do is capture the original filename, check it against a validFilenameChars function, then present the filename to the user...
Read more >
Image Tools Image upload filenames - TinyMCE
Any way to pass the real image name? ... //need to rememeber the original filename var setImageData = function(contentDocument){ var ...
Read more >
Sample code TinyMce image upload - MSDN - Microsoft
To enable user to upload image file and display it in TinyMCE editor, ... image code', images_upload_handler: function (blobInfo, success, ...
Read more >
Tinymce 4.9.8 upload image - CodeIgniter Forums
images_upload_handler : function (blobInfo, success, failure, progress) { var xhr, formData; xhr = new XMLHttpRequest();
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found