Check if argument is empty and then set new profile picture


So below, I will go into detail on what I’m trying to achieve and if anyone can help me, it would be extremely helpful.

I have the below metabox that pulls in and store a picture (The full code is not provided and the var_dump has been taken out since I took this picture).
enter image description here

Once a picture is uploaded, it stores it in the database as _profile_photo (Once it it removed, it removes _profile_photo from the database)
enter image description here

I have some code that pulls and update_post_meta for _profile_photo_octopus which is either stored as an object or it’s NULL. Note: There will be _profile_photo and _profile_photo_octopus present.
enter image description here

What I’m trying to achieve:
How can I make it so that when _profile_photo is present, to use that profile picture, but if it’s not present to fallback on _profile_photo_octopus and just store the object in the field.

Here is the code:

function get_employee_profile_photo_args() {
    return array(
        'data'          => array(
            'name'      => 'employee_profile_photo',
            'type'      => 'image',
            'width'     => 140,
            'height'    => 190,
            'nonce'     => wp_create_nonce('employee_profile_photo_nonce')
        'class'         => 'fh-meta-box',
        'field'         => '_profile_photo'

Here is the piece of the metabox:

    __('Profile Photo', PS),
    NS . 'employee_profile_photo',

Here is the code to display the box:

function employee_profile_photo()
        $args = get_employee_profile_photo_args();
        $meta_box = FleishmanHillardExtensionMetaBoxdisplay_upload_button($args);
        echo $meta_box;
, , Sema 4 years 2019-11-05T16:18:02-05:00 0 Answers 55 views 0

Leave an answer