\WP_Stager_Integration\Event::get_main_image_alt(array $event): string
\WP_Stager_Integration\Event::get_main_image_alt(array $event): stringDescription
Gets the main image alternative text from event media.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$event | array | Raw Stager event data. |
$fallback | string | Value when no alternative text is set on mainImage. |
Returns:
string
Information
| File | class-event.php line 1327 |
|---|
Full Code
/**
* Gets the main image alternative text from event media.
*
* @param array $event Raw Stager event data.
* @param string $fallback Value when no alternative text is set on mainImage.
*
* @return string
*/
public static function get_main_image_alt( $event ) {
// Type casting
$event = (array) $event;
// Get data
$media = (array) ( $event[ 'media' ] ?? array());
$main_image = (array) ( $media[ 'mainImage' ] ?? array() );
$alt = (string) ($main_image[ 'alternativeText' ] ?? $event[ 'name' ] ?? '');
return $alt;
}💡 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!

