WordPress.org

Ready to get started?Download WordPress

Forums

UploadPlus : File Name Cleaner
[resolved] Custom prefix options? (5 posts)

  1. Alex
    Member
    Posted 10 months ago #

    Hi there and thank you for your great work,

    What are the possible options for the custom prefix box? Can it take any loop variables or just plain text?

    Regards,
    Alex.

    http://wordpress.org/extend/plugins/uploadplus/

  2. Paolo T. (pixline)
    Member
    Plugin Author

    Posted 10 months ago #

    Hi Alex, custom prefix are actually static only ( = plain text) for both security and performance reasons.

    The issue is that this plugin acts on a very low level on files uploading, so loop variables and the like won't probably be available at the time our plugin is triggered in about 9 out of 10 runs. We too couldn't recognize a lot of use cases and we're learning about them almost daily! :-)

    That said, we're considering a couple of enhancements on custom prefixes and I'd like to know more about your use case: maybe it's something we can achieve in a different way.

    Thank you for caring!
    p.

  3. Alex
    Member
    Posted 10 months ago #

    Thanks Paolo, no problem, in my case I'd like to have the file renamed using the post title,

    In the mean time I managed to rename the file using the post title by adding the following code to the core.class.php and admin.class.php files.

    In core.class.php, on line 100:

    case "C": $file_name = str_replace( array(".","_","-"," ") ,$sep, sanitize_title( get_the_title() ) ).$sep.$file_name; break;

    In admin.class.php, line 85:

    "C" => 'Post title and the filename'

    So far it works really well by adding the post name before the filename which is pretty much what I need. I did not looked into the "demo string" feature and I realise that I have to use an IF somewhere to intercept situations where the post does not have a name defined.

    But so far so good, I'm happy with this. That's why open source rocks. And that's why I thank you again ;-)

  4. Paolo T. (pixline)
    Member
    Plugin Author

    Posted 10 months ago #

    The issue with this approach - as you already know - is that it won't work with media uploads from outside a post/page (i.e. direct upload in the media library) : they can't have that context if no new post/page is hosting this uploaded file.

    We need to think a bit more about it, find out something a bit more comprehensive for the average user out there. But that's open source: if you're fine with that solution go for it! :)

  5. Alex
    Member
    Posted 10 months ago #

    You are right, I just filtered out the Media section on the Admin menu :D
    Thanks again A LOT! I'll keep an eye on your plugin as it really helped me.

Reply

You must log in to post.

About this Plugin

About this Topic