Chrome not rendering video upon upload

Last modified
Sunday, February 5, 2017 - 21:26

And this happens with Drupal too!

When creating a node that has for instance a field where you place the embedded code of a youtube video, once submitted the add form, on Chrome the video does not get displayed unless you refresh the page. Basically this is how Chrome prevents XSS attacks.

What i did to solve this momentarily ( workaround) is adding a Javascript refresh page condition on my template.php:


function my_theme_preprocess_html(&$variables) {
	// on chrome we need to reaload the page so the uploaded video can be shown
	// this is due how Chrome prevents XSS (cross-site scripting)
	$u_agent = $_SERVER['HTTP_USER_AGENT']; 
	if(preg_match('/Chrome/i',$u_agent)){ 
	  $bname = 'Google Chrome'; 
	 $ub = "Chrome";	
  }
  if($ub == 'Chrome')
  	$variables['attributes_array']['onLoad'] = "if (location.href.indexOf('reload')==-1) location.replace(location.href+'?reload')";
}

another point of view: http://stackoverflow.com/questions/6838172/embedded-video-not-rendering-in-chrome-on-first-load-after-embed-code-is-saved-t

Topic

Add new comment

This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.