\WP_Stager_Integration\Event::get_main_image_url(array $event): string

Description

Gets the main image URL from event media.

Prefers the mainImage object; falls back to deprecated mainImageUrl.

Parameters:

ParameterTypeDescription
$event array Raw Stager event data.

Returns:

string

Information

Fileclass-event.php line 1306

Full Code

/**
 * Gets the main image URL from event media.
 *
 * Prefers the mainImage object; falls back to deprecated mainImageUrl.
 *
 * @param array $event Raw Stager event data.
 *
 * @return string
 */
public static function get_main_image_url( $event ) {

    // Type casting
    $event = (array) $event;

    // Get data
    $media      = (array) ( $event[ 'media' ] ?? array());
    $main_image = (array) ( $media[ 'mainImage' ] ?? array() );
    $url        = (string) ($main_image[ 'url' ] ?? $media[ 'mainImageUrl' ] ?? '');

    return $url;
}

💡 If you ever get stuck or have a question, please check our FAQs, our Free Integration Service, our paid Full Integration Service, or reach out to us!

Get WP Stager Integration

🎁 Limited offer: Use code WELCOME26 to get your first month for free!