• Resolved feijon

    (@feijon)


    Hi, I need to change/renaming the image when uploading.
    I’m using the code below and it works perfectly on the wordpress backend, however, it’s not working on the WC Vendors frontend form, can you help me solve this please.

    Código:

    /*Renaming attachment files to the post title*/
    function file_renamer( $filename ) {
        $info = pathinfo( $filename );
        $ext  = empty( $info['extension'] ) ? '' : '.' . $info['extension'];
        $name = basename( $filename, $ext );
    
        if( $post_id = array_key_exists("post_id", $_POST) ? $_POST["post_id"] : null) {
            if($post = get_post($post_id)) {
                return $post->post_title . $ext;
            }
        }
        
        $my_image_title = $post;
        
        $file['name'] = $my_image_title  . - uniqid() . $ext; // uniqid method
        // $file['name'] = md5($name) . $ext; // md5 method
        // $file['name'] = base64_encode($name) . $ext; // base64 method
    
        return $filename;
    
      }
    add_filter( 'sanitize_file_name', 'file_renamer', 10, 1 );
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Mark Kevin

    (@mkesteban08)

    Hi @feijon ,

    Could you please let me know if you’re trying to change the name of the featured image only or all the images involved within a product so I could double-check with our developers what are the specific variables that we are using in our front-end form.

    Plugin Support Mark Kevin

    (@mkesteban08)

    Hi @feijon ,

    Just to follow this up, please take note that the vendor prefixes are already built-in within our WC Vendors Pro. If ever you are having an issue with it if you’re using WC Vendors Pro – please take note that you have purchased access to our support via our premium plugins and you can submit a ticket here : https://www.wcvendors.com/submit-ticket/ please be sure to include your license key and order number.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Rename name image upload’ is closed to new replies.