Support » Plugin: Media Library Assistant » Compatibility with “Bulk Media Register”-plugin or trigger mapping manually

  • Resolved leanderbraunschweig

    (@leanderbraunschweig)


    Hi there,

    first of all: I am at awe with regards to the detail, scope and documentation of this plugin, very much appreciated!!

    I have a question regarding our image workflow, precisely the usage of the “Bulk Media Register“-plugin.

    We have set everything up so that upon manually uploading an image the XMP metadata gets mapped to both custom fields as well as taxonomy tags so that we can utilize these infos within WordPress for sorting and filtering the media.

    BUT when uploading images via the “Bulk Media Register”-plugin the Media Library Assistant actions are not being triggered / processed. This does make sense since the other plugin follows a – more or less – custom approach of handling media-imports.

    I am hoping that there is a rather simple filter / action we can use to let the newly uploaded images be processed via MLA since the manual “Execute”-functionality is pretty much what we’d need here and could be integrated into the registering process.

    Would someone be able to shed some light on how to achieve this in a straight forward way? Kind of like executing a rule for a specific image ID?

    Looking forward to hearing your thoughts on this…!

    Thanks again for everything and sharing such a powerful toolset.

    Regards,
    Henning

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author David Lingren

    (@dglingren)

    Thanks for the positive MLA feedback, for posting the link to the Bulk Media Register plugin and for your question.

    Bulk Media Register uses an AJAX request to process the Bulk Register and Select Register tasks. To minimize memory and processing load, MLA does not load its mapping logic for AJAX requests it does not recognize. In the “IPTC & EXIF Processing Options” section of the Settings/Media Library Assistant Documentation tab you can find the solution:

    Some plugins support file uploads from the WordPress “front end”, usually by using the WordPress “AJAX” support. To enable mapping when these plugins are used you must add an entry to your wp-config.php file so MLA will load the mapping code:

    define( 'MLA_AJAX_EXCEPTIONS', 'wfu_ajax_action,upload_ugc' );

    You can find more information and tips in the Documentation tab, but that’s the basic answer. Bulk Media Register uses a “bulkmediaregister-ajax-action” action for its work, so for your application the entry would be:

    define( 'MLA_AJAX_EXCEPTIONS', 'bulkmediaregister-ajax-action' );

    Adding this line to the wp-config.php file solves the problem on my system. Please give that a try and let me know if it works for you.

    I am marking this topic resolved, but please update it if you have problems or further questions regarding the solution outlined above. Thanks for your interest in the plugin.

    Thread Starter leanderbraunschweig

    (@leanderbraunschweig)

    Hi David,

    many thanks for getting back and sorry for the late reply – I was away on holidays and only got back yesterday…

    Unfortunately I have missed out on a crucial info and thus the issue isn’t resolved for us:

    We make use of the Cron add-on for the “Bulk Media Register” plugin, which allows us to run the registering process on a command line base.

    There are no AJAX-calls being made and therefore the solution you offered doesn’t apply.

    Again, sorry for not including this in the initial request / post as this would have cleared things up and not have occupied your time. I hope that the info is useful for other, ‘regular’ users of the “Bulk Media Register” plugin though…

    So essentially the cron add-on simply calls the regist()-function (see line 474 ff. in /lib/class-bulkmediaregister.php) via do_action( 'bmr_regist', $file, $uid ).

    Is there an easy way you can think of to either

    • hook into the native functions wp_insert_attachment(), update_post_meta(), wp_update_post() or wp_update_attachment_metadata() via MLA
    • add a function call that would trigger the MLA registration process

    ???

    We have forked the plugin anyhow so it would also be possible to directly edit the code and tweak it accordingly to achieve compatibility (although I am always striving for a clean, update-safe approach that benefits other users just the same).

    Many thanks for your insights here.

    Regards,
    Henning

    Plugin Author David Lingren

    (@dglingren)

    Thanks for your update with the additional information; very helpful.

    You should be able to adapt one of the MLA example plugins to accomplish your goal. Have a look at the “MLA Postie Post After Example” plugin. Navigate to the Settings/Media library Assistant Documentation tab and click the “Example Plugins” button. Type “postie” in the text box and click “Search Plugins” to filter the table.

    You are looking for the “MLA Postie Post After Example” plugin. Find that plugin and hover over the title in the left-most column. Click the “View” rollover action to have a look, or the “Download” action to get a local copy you can work with.

    You can hook the bmr_regist action with a priority higher than 10 so it runs after the regist() function. Retrieve the bulkmediaregister_output user option using the supplied $uid so you can get the attachment ID. The use the ID to run the MLA functions in the foreach loop.

    Of course, you can remove the SQL query logic since you have another way of getting the ID. In its place you will probably have to add this code to load the required MLA classes:

    		// Template file and database access functions.
    		require_once( MLA_PLUGIN_PATH . 'includes/class-mla-data-query.php' );
    		MLAQuery::initialize();
    
    		require_once( MLA_PLUGIN_PATH . 'includes/class-mla-data.php' );
    		MLAData::initialize();
    
    		// Shortcode shim functions
    		require_once( MLA_PLUGIN_PATH . 'includes/class-mla-shortcodes.php' );
    		MLAShortcodes::initialize();
    
    		require_once( MLA_PLUGIN_PATH . 'includes/class-mla-shortcode-support.php' );
    
    		// Plugin settings management
    		require_once( MLA_PLUGIN_PATH . 'includes/class-mla-options.php' );
    		MLAOptions::initialize();
    

    I hope that gets you started on a simple fix for your application. Let me know if you have any problems or further questions regarding the above suggestions.

    Thread Starter leanderbraunschweig

    (@leanderbraunschweig)

    Hey David,

    many thanks for this!! Exactly the push into the right direction I was hoping for.

    Will look into the code and report back once I have found a solution for our problem.

    Kind regards,

    Henning

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.