Skip to content

Instantly share code, notes, and snippets.

@azraf
Created May 21, 2021 03:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save azraf/aabb75d0f4b2c6846d0037dae9cec4eb to your computer and use it in GitHub Desktop.
Save azraf/aabb75d0f4b2c6846d0037dae9cec4eb to your computer and use it in GitHub Desktop.
I got an issue with a client website that all images are getting disappear class automatically. I dont have time to check all the codes. So I just make that class opacity function override. Best practice is to remove the main, class, but if you need some time to fix that, you may use this kind of not-recommended tricks to buy you some time.
<?php
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* Plugin Name: Image Disappear Fix
* Plugin URI: http://makewebsmart.com/
* Description: Image Disappear Fix for "disappear" Class
* Version: 1.0
* Author: Azraf
* Author URI: http://azraf.me
* Author email: c.azraf@gmail.com
*/
function mws_wp_img_disappear_fix() {
?>
<script type="text/javascript">
window.onload = function() {
var x = document.getElementsByClassName("disappear");
var i;
for (i = 0; i < x.length; i++) {
x[i].style.opacity = "1";
}
};
</script>
<?php
}
add_action( 'wp_footer', 'mws_wp_img_disappear_fix' );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment