Support

Account

Forum Replies Created

  • I also have this issue, can someone from the team look why this isn’t working?

    Here is the video I have an issue with:
    https://www.youtube.com/watch?v=o_5oYuDY2qM

  • Add this to functions.php file:

    add_action( 'run_video_embed', 'video_embed' );
    
    function video_embed( $context ) {
    
        $video = get_field( 'media' );
    	
    	if ( $video ) {
    		// Add autoplay functionality to the video code
    		if ( preg_match('/src="(.+?)"/', $video, $matches) ) {
    			// Video source URL
    			$src = $matches[1];
    			
    			// Add option to hide controls, enable HD, and do autoplay -- depending on provider
    			$params = array(
    				'controls'    => 1,
                    'hd'        => 1,
                    'fs'        => 1,
                    'rel'        => 0,
                    'modestbranding' => 1,
    				'autoplay' => 0
    			);
    			
    			$new_src = add_query_arg($params, $src);
    			
    			$video = str_replace($src, $new_src, $video);
    			
    			// add extra attributes to iframe html
    			$attributes = 'frameborder="0"';
    			
    			$video = str_replace('></iframe>', ' ' . $attributes . '></iframe>', $video);
    		}
    	
    		echo '<div class="video-embed">', $video, '</div>';
    	}
    }

    and add this in Twig

    {% do action('run_video_embed') %}

  • Forgot to say I use Timber, and Twig to show the ACF field so that might be an issue anyone knows how to add attributes to that? Also, why don’t the field have attributes field coded in so we can add it in the backend?

  • Where did you add that code in what file?

Viewing 4 posts - 1 through 4 (of 4 total)