0

When I upload audio with wp media uploader using the following code, I can see all this data:

wp.media({
      library:{
      type: 'audio'
 }
 })
  .on("select", function(){
    var attachment = custom_uploader.state().get("selection").first().toJSON();
      console.log(attachment)
})
.open();

Is there an Wordpress hook or filter I can use to manually fetch this data? For example, if I read mp3 files though folder, could I pass song to some Wordpress function to return me this data?

{
    "id": 6343,
    "title": "La preghiera del monaco e la lotta con Dio",
    "filename": "3.-NOV-2018-24-MIN-9.6.1994-La-preghiera-del-monaco-e-la-lotta-con-Dio.mp3",
    "url": "http://localhost/xampp/wp/wp-content/uploads/2024/02/3.-NOV-2018-24-MIN-9.6.1994-La-preghiera-del-monaco-e-la-lotta-con-Dio.mp3",
    "link": "http://localhost/xampp/wp/la-preghiera-del-monaco-e-la-lotta-con-dio/",
    "alt": "",
    "author": "1",
    "description": "\"La preghiera del monaco e la lotta con Dio\" from Venerdì 09 06 1994 by Divo Barsotti. Genre: Tempo Ordinario.",
    "caption": "",
    "name": "la-preghiera-del-monaco-e-la-lotta-con-dio",
    "status": "inherit",
    "uploadedTo": 0,
    "date": "2024-02-19T18:03:29.000Z",
    "modified": "2024-02-19T18:03:29.000Z",
    "menuOrder": 0,
    "mime": "audio/mpeg",
    "type": "audio",
    "subtype": "mpeg",
    "icon": "http://localhost/xampp/wp/wp-includes/images/media/audio.svg",
    "dateFormatted": "February 19, 2024",
    "nonces": {
        "update": "37c930fa04",
        "delete": "ce25afeed7",
        "edit": "d61dc8cac4"
    },
    "editLink": "http://localhost/xampp/wp/wp-admin/post.php?post=6343&action=edit",
    "meta": {
        "artist": "Divo Barsotti",
        "album": "Venerdì 09 06 1994",
        "bitrate": 48738.3692789684,
        "bitrate_mode": "vbr"
    },
    "authorName": "ap8btry",
    "authorLink": "http://localhost/xampp/wp/wp-admin/profile.php",
    "filesizeInBytes": 8807228,
    "filesizeHumanReadable": "8 MB",
    "context": "",
    "fileLength": "23:58",
    "fileLengthHumanReadable": "23 minutes, 58 seconds",
    "image": {
        "src": "http://localhost/xampp/wp/wp-content/uploads/2024/02/1-SET-2018-17-MIN-25-9-1998-Tu-solo-Signore-sei-l_unico-mio-bene02-mp3-image.jpg",
        "width": 512,
        "height": 512
    },
    "thumb": {
        "src": "http://localhost/xampp/wp/wp-content/uploads/2024/02/1-SET-2018-17-MIN-25-9-1998-Tu-solo-Signore-sei-l_unico-mio-bene02-mp3-image.jpg",
        "width": 80,
        "height": 80
    },
    "compat": {
        "item": "",
        "meta": ""
    }
}

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.