WP Document Revisions
[resolved] Automatic Post title from filename (2 posts)

  1. neocreo
    Posted 2 years ago #

    I have a client who prefers to upload first and ask questions later - for instance "what was the name of that file I just uploaded?"

    Does anyone know of a way to grab the filename on upload and populate the post-title field (if empty of course).

    I have a little idea of how this could be done via jQuery, but am not sure on how I can hook it to run when the file has uploaded.

    Any suggestions or better solutions are welcome.


  2. neocreo
    Posted 2 years ago #

    OK, if anyone is interested, I solved it the following way - and hopefully the author sees this - might add this to the next version of the plugin.

    I only needed this run when first uploading a document, so I hacked the following file: wp-content/plugins/wp-document-revisions/js/wp-document-revisions.js
    I ran the code through jspretty to find the correct place.
    find the prototype
    WPDocumentRevisions.prototype.postDocumentUpload = function (file, attachmentID)
    At the end of the function I added the following jQuery

    var filename = file.split(".")[0];
                if (this.window.jQuery('#title').val() == '') {

    What is does is simply checking whether the document title is empty, if so it will set the focus on the field and fill it with the file-name with the file ending removed.

    I think it could be useful for new users, especially since the filename is not visible anywhere after upload.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WP Document Revisions
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic