• Resolved orelqr

    (@orelqr)


    Hi,
    I’m using WooCommerce and dokan as multivendor plugin.

    Sadly, by default Dokan don’t have the option to add Media files in product description like in WooCommerce.

    It looks like this:

    View post on imgur.com

    So I found a way to add “Add Media” option that exists in the normal WooCommerce description editor to here as well using this code :

    add_action(‘dokan_product_short_description’, ‘add_demo_description’);
    function add_demo_description(){
    }

    And now it looks like this :

    View post on imgur.com

    and it actually works, I can add media library items and upload new ones through the Dokan vendor dashboard, and they also appear on the product page description, which is exactly what I need.

    So it looks like this on product page:

    View post on imgur.com

    So now that users can add their Media in product description, I understood there is a new problem.
    the problem is that they can upload any file type here, which is not good because I don’t want people uploading weird stuff to the product description, the only relevant file in my case is MP3, That’s the only file type I want people to be able to insert into the product description.

    Its also important to be able to limit file size and file amount, so trolls & bots wont be able to upload 10k files at 10gb each and destroy my server.

    Any idea what I can do to ensure people can’t insert anything other than MP3 to the product description?

    P.S: If you know of ways to style / change that default mp3 media player to something better that would be great.

    Thank you!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hello @orelqr ,

    The code you have added has an undefined constant which might create an issue with the latest PHP versions. Instead, you may use the code given below which will allow you to add media to the short description and description.

    #-- Short description Media button --#
    add_filter('dokan_product_short_description', function(){
      return array(
        'media_buttons' => true
      );
    });
    #-- Long description Media button --#
    add_filter('dokan_product_description', function(){
      return array(
        'media_buttons' => true
      );
    });

    After adding these codes, you shall see the add media button on your vendor dashboard product short and long description fields.

    Now, to remove the file type and size upload problem, you may use a third-party plugin rather than using a hard code. You can also restrict file type and size upload by user roles. I would suggest using WP Upload Restriction plugin. With this plugin, you can limit upload size and type. Though this is not tested by us since it’s a third-party plugin but it should work.

    To change the default media player style, you may take the help of this article: https://www.cssigniter.com/css-style-guide-for-the-default-wordpress-media-player/

    Hope this helps.

    Best Regards!

    Thread Starter orelqr

    (@orelqr)

    Yo great help, any idea how to add this to Product Popup / the normal popup upload form?

    Hello @orelqr ,

    To add this to the product popup form or the new product upload form, you will need customizations. As per our support policy, we are unable to provide any custom solutions.

    But I am keeping this topic open so that anyone can contribute to help you.

    Also, you can look at this video to get an idea about how can you add a custom field in the product pop-up form: https://www.youtube.com/watch?v=uBvrCUPa-nY&ab_channel=nayemDevs

    Regards!

    Hello @orelqr ,

    Due to inactivity, we are marking this topic as resolved. Feel free to open a new one if you face any further issues.

    Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Disable certain file types from upload’ is closed to new replies.