Create standard image if your article doesn't contain images using JavaScript

There are some articles. It's not possible to add an image that expresses the content. You can create a standard image for all content that doesn't contain images automatically using JavaScript

<div id="content">
There are some articles. It's not possible to add an image that expresses the content. You can create a standard image for all content that doesn't contain images automatically using JavaScript
</div>

<!--Create standard image if your article doesn't contain images -->
<script type='text/javascript'>
//<![CDATA[
var detimg = document.getElementById("content");
var ff= detimg.getElementsByTagName("img").length;

if(ff<1){

document.getElementById("content").innerHTML+="<img src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQaPVowepmXig9tengifdWVmU04GM4Bvd_VP9Ml2QP07vagCh8x-Rzk08sngTp1T6skRzkIIzJmrOHDlfxU3iMzuaV7MOSP1sZGxmLKVuqCe0tMJMZVcKhTO2T9kD2fBNX52FiC7l0qTtX/s0/businessman-481113_640+%25281%2529.jpg' />"

alert("! this article doesn't contain images")
}

//]]>
</script>
<!--Create standard image if your article doesn't contain images -->







Create standard image if your article doesn't contain images using JavaScript

© 2025 Manajmnt code

Share to :

Related

Comments