Search code examples
tinymce

Can we count how many images are within TinyMCE's editor blob box and limit them to only 10 per post?


I've been struggling trying to find a way to limit how many images can be uploaded to editor per 'post', like each post description may only have 10 images in my case, but I have no idea how to do it so, can someone please help me?


Solution

  • There is no "default" option that could be set in the TinyMCE config to limit the number of images. But there are ways to build your own logic outside the editor that would provide such a limitation:

    • Add the Image Tools plugin and set up an image proxy that would check whether the uploaded image fits the limit.
    • If automatic uploads are activated, you can build a limitation logic into the script that handles the uploads. The default PHP example of the script can be found here, but it needs to be modified if you want to limit the number of uploads.