Custom Layer Values


You can extend the default layer mapping options of our WordPress plugin with custom values.

Custom Text Layer Value

Add a custom dropdown value for text layers by using the placid_add_text_field function.

/images/docs/wordpress-text-field.png

The closure below will be run every time an image is being generated and has to return a string value.

function placid_init_callback() {
    placid_add_text_field('movie-title', "Movie Title", function ($params) {

        // - the $params array will hold the necessary info to resolve the custom layer value

        $params['object_type']; // - post, tag, category  
        $params['object_id']; // - null || id 
        $params['post_type']; // - null || custom_post type = 'movies'
        $params['image']; // - ogimage/twitter/pinterest

        // - must return string
        return "MOVIE TITLE";
    });
}

// - You should call the closures in an init callback
add_action( 'init', 'placid_init_callback' );

Custom Image Layer Value

Add a custom dropdown value for image layers by using the placid_add_image_field function.

/images/docs/wordpress-text-field.png

The closure below will be run every time an image is being generated and has to return a string value.

function placid_init_callback() {
    placid_add_image_field('movie-poster', "Movie Poster", function ($params) {

        // - the $params array will hold the necessary info to resolve the custom layer value

        $params['object_type']; // - post, tag, category  
        $params['object_id']; // - null || id 
        $params['post_type']; // - null || custom_post type = 'movies'
        $params['image']; // - ogimage/twitter/pinterest

        // - must return string with publicly accessible URL of an image
        return "https://URL-TO-POSTER.png";
    });
}

// - You should call the closures in an init callback
add_action( 'init', 'placid_init_callback' );