Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter tplunkett87

    (@tplunkett87)

    Thanks for explaining the different purposes of the two filters. I did not grasp that and it obviously explains why they behaved the way they did. I agree this is a very practical example of extending MLA’s functionality to meet a custom need. 👍 When I finally get the site completed I will circle back around and share it here with you so you can see how I leveraged this custom field information.

    Thread Starter tplunkett87

    (@tplunkett87)

    David – Thank you so much for your very thorough explanation and answer to my questions. I was able to largely understand your answer and I have implemented the changes you suggested. I first tried the ‘mla_evaluate_custom_data_source’ function but when I processed the Map Custom Field metadata the custom field was not populated. I then tried the second function ‘mla_evaluate_custom_data_source’ and it works perfectly. I did check the Attachment Metadata for my images that I tested the first function on and they had width and height array values so I am unsure why it did not work. But of course I am very happy the second function is working properly.

    Thank you again for your work to develop MLA and your support on my question. I hope that this help you provided me can be applied by someone else who has a similar question/need.

    Thread Starter tplunkett87

    (@tplunkett87)

    Hi David,

    I have been looking at the function and have a couple of question that may help get me going.

    I want to ask you about the function parameters:

    mla_evaluate_custom_data_source( $custom_value, $post_id, $category, $data_value, $attachment_metadata )
    
    @param	string	NULL, indicating that by default, no custom value is available
    @param	integer	attachment ID for attachment-specific values
    @param	string 	category/scope to evaluate against: custom_field_mapping or single_attachment_mapping
    @param	array	data source specification ( name, *data_source, *keep_existing, *format, mla_column, quick_edit, bulk_edit, *meta_name, *option, no_null )
    @param	array 	_wp_attachment_metadata, default NULL (use current postmeta database value)

    1. As I understand it all of these parameters are being passed into this function such that they are available for my custom PHP code to work with.

    How do I reference the metadata in the PHP code I will insert in the function? Would my code look something, roughly like this:

    if ($attachment_metadata.COMPUTED.Width/$attachment_metadata.COMPUTED.Height>1) {
    $custom_value=’Landascape’;}
    else
    {$custom_value=’Portrait’;}

    2. How do I “Call” this function in the MLA settings so that I tell it to populate a custom field I create in ACF called “calculated_orientation”? Is this call specified somehow in the Custom Fields tab of the MLA Admin screen?

    Thank you!

    • This reply was modified 4 years, 2 months ago by tplunkett87.
    • This reply was modified 4 years, 2 months ago by tplunkett87.
    • This reply was modified 4 years, 2 months ago by tplunkett87.
    • This reply was modified 4 years, 2 months ago by tplunkett87.
    Thread Starter tplunkett87

    (@tplunkett87)

    Thank you David for pointing me in the right direction. I have dabbled in php before so I may have some luck giving this a go. I will work on it and get back to you in a day or two. Thanks again!

Viewing 4 replies - 1 through 4 (of 4 total)