Advertisement
Guest User

WP Alchemy MediaAccess.php hack to extract attachment ID

a guest
Apr 12th, 2011
886
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /////////////////////////////////////////////////////////////////////////////////
  2. // Added by Dameian on 4/11/2011 to allow for extraction of the attachment's ID
  3. // and population of a preview area.
  4.            
  5. // Isolate the attachment's ID
  6. var mediaID = html.match(/wp-image-(.*)"/i);
  7. mediaID = (mediaID && mediaID[1]) ? mediaID[1] : '' ;                          
  8.            
  9. // Pass the attachment ID to a hidden field with ID #media_id
  10. $(wpalchemy_mediafield_selector).closest('.wpa_group').find('#media_id').val(mediaID);
  11.            
  12. // Send a preview thumb to a preview area
  13. $(wpalchemy_mediafield_selector).closest('.wpa_group').find('.preview').html(html);
  14.            
  15. // Maybe make our media ID global and available to things like AJAX?
  16. // WPAlchemyMediaID = mediaID;
  17.            
  18. /////////////////////////////////////////////////////////////////////////////////
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement