Home / Admin / Show the Speaker Photo Above the Speaker Details
Duplicate Snippet

Embed Snippet on Your Site

Show the Speaker Photo Above the Speaker Details

Sugar Calendar's speaker page shows the detail fields and the biography, but it does not show the speaker photo in that block. This snippet adds the featured image at the top of
the block, above the detail fields. Many themes already show the featured image at the top of the page, so check a speaker page after enabling this. If the photo now appears twice,
your theme is already covering it and you do not need this snippet.

Code Preview
php
<?php
/**
 * Show the speaker featured image above the speaker detail fields.
 *
 * Sugar Calendar renders the detail fields on `sc_speaker_details` at priority 10,
 * so hooking at 5 puts the image first. Requires Sugar Calendar Pro 3.7.0+.
 */
add_action( 'sc_speaker_details', 'sc_snippet_speaker_featured_image_first', 5 );
function sc_snippet_speaker_featured_image_first( $speaker_data ) {
	if ( empty( $speaker_data['featured_image'] ) ) {
		return;
	}
	printf(
		'<div class="sc-speaker-details-inner-featured-image" style="margin-bottom:1.5em;">' .
			'<img src="%s" alt="%s" style="max-width:100%%;height:auto;border-radius:6px;" />' .
		'</div>',
		esc_url( $speaker_data['featured_image'] ),
		esc_attr( $speaker_data['title'] ?? '' )
	);
}

Comments

Add a Comment