• Resolved Superbobo75

    (@superbobo75)


    Code from FAQ page for insert your custom part file name only works if is not commented in the this plugin. If you move to functions.php, showing the error “Warning: call_user_func_array() expects parameter 1 to be a valid callback, first array member is not a valid class name or object in C:\wamp\www\site-name\wp-includes\plugin.php on line 213”.

    I have version 4.2.4 WP

    https://www.ads-software.com/plugins/media-file-renamer/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Jordy Meow

    (@tigroumeow)

    Hello Superbobo,

    It is because you are not using it within an object. You should modify the code as follows:

    add_filter( 'mfrh_new_filename', 'my_filter_filename', 10, 3 );
    
    function my_filter_filename( $new, $old, $post ) {
      return "renamed-" . $new;
    }

    Please try it ??

    Thread Starter Superbobo75

    (@superbobo75)

    Super. It works. thanks

    Plugin Author Jordy Meow

    (@tigroumeow)

    You already coded your own function? Would you mind sharing it here? Some people might want to use it too ??

    Thread Starter Superbobo75

    (@superbobo75)

    I’m not a programmer. PHP understand very decent ??

    But I wondered solutions renaming images with the same label ??

    To supplement the file name of the image file ID.

    PS: str_replace is there because I wanted renemad at the end of the filename

    add_filter( 'mfrh_new_filename', 'my_filter_filename', 10, 3 );
    
    function my_filter_filename( $new, $old, $post ) {
    
      $new = str_replace(".jpg","-renamer-" . $post['ID'] . ".jpg",$new);
      return $new;
    }
    Plugin Author Jordy Meow

    (@tigroumeow)

    So you just wanted to have the ID of the media at the end of the filename? Yeah in that case that works ??

    Thread Starter Superbobo75

    (@superbobo75)

    ID in the file name solves this problem https://www.ads-software.com/support/topic/suggestion-122

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Function from FAQ for insert custom part file name, view error’ is closed to new replies.