spoonFedForehead
4/26/2018 - 7:27 PM

image left/right repeater

<?php
/**
 * Image left right
 *
 * @package Base
 */
// ACF
$title            = get_sub_field( 'content_title' ); // Text
$content          = get_sub_field( 'content_content' ); // WYSIWYG Editor
$image            = get_sub_field( 'content_image' ); // Image
$image_position   = get_sub_field( 'content_image_position' ); // Options: Left, Right. Default: Left.
$background_color = get_sub_field( 'content_image' );

// Modifier
$block_modifier_position = $image ? $image_position : 'center';

switch ( $background_color ) {
	case 'light-blue':
		$background_color = '#1E2A43';
		break;
	case 'medium-blue':
		$background_color = '#336293';
		break;
	case 'dark-blue':
		$background_color = '#5F8AB1';
		break;
	default:
		$background_color = '#FFFFFF';
}
?>

<div class="block-content block-content--<?php echo esc_attr( $block_modifier_position ); ?>">
	<?php base_display_image_acf( $image, 'large', [ 'block-content__image', "block-content__image--$image_position" ] ); ?>

	<?php if ( $content ) : ?>
		<div style="background-color:<?php echo esc_html( $background_color ); ?>;"
			class="wysiwyg-content block-content__content block-content__content--<?php echo esc_attr( $block_modifier_position ); ?> block-content__content--<?php echo esc_attr( ( $background_color === '#FFFFFF' ) ? 'white' : 'dark' ); ?>">
			<?php if ( $title ) : ?>
				<h2><?php echo esc_html( $title ); ?></h2>
			<?php endif; ?>

			<?php echo wp_kses_post( $content ); ?>
		</div>
	<?php endif; ?>
</div>