This might sound strange, but can I still display fallback image in that case?
Since video elements in mobile (Android & iOS) will open its native video player app when clicked, I want to show GIF version of the video (which I will place as the fallback image) for Android & iOS. I know how to detect whether the browser is mobile or not via Javascript, I just need some advice on best practice.
What I'm doing
<video>
<source mp4>
<source ogg>
<source webm>
<img src="*.gif">
</video>
Then in the js
if(site.isMobile()){
$('video').hide();
$('video img').show();
}
Of course it doesn't work since the img is inside video. I figure I can clone the img and append it before the video element and then hide the video element, something like this :
if(site.isMobile()){
$('video img').clone().prependTo('video'); // just some pseudocode
$('video').hide();
}
Is it a good practice though? Is there any simpler solution?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…