- This topic has 10 replies, 2 voices, and was last updated 8 years, 1 month ago by
Tom.
-
AuthorPosts
-
February 27, 2018 at 3:39 pm #507382
Mary Pearson
I want a hover image on home page at https://maceducationcanada.com/ so have included the following HTML
<div class="paytostudy"><a target="_blank" href="https://paytostudy.com"><img src="https://maceducationcanada.com/eric-content//uploads/2018/02/paytostudy-min.jpg" /></a></div>with CSS of
.paytostudy {
background-image: url(“uploads/2018/02/paytostudy-min.jpg”) no-repeat;
display: inline-block;
height: 140px;
width: 513px;
}.paytostudy:hover {
background-image: url(“uploads/2018/02/paytostudy-hover-min.jpg”) no-repeat;
}Unfortunately WP keeps stripping out the code. I have tried using
andtags and have added to my functions.php in the child-theme // stop wp removing div tags function ikreativ_tiny_mce_fix( $init ) { // html elements being stripped $init['extended_valid_elements'] = 'div[*]'; // pass back to wordpress return $init; } add_filter('tiny_mce_before_init', 'ikreativ_tiny_mce_fix'); Nothing seems to work. How do I stop WP from stripping out my code so that my hover image will work? Thanks!February 27, 2018 at 9:31 pm #507522Tom
Lead DeveloperLead DeveloperWhich code is it stripping out?
February 28, 2018 at 7:17 am #507970Mary Pearson
It got stripped out from my original post here. I’ll try putting it in
tags.<div class="paytostudy"><a target="_blank" href="https://paytostudy.com"><img src="https://maceducationcanada.com/eric-content//uploads/2018/02/paytostudy-min.jpg" onmouseover="this.src='https://maceducationcanada.com/eric-content//uploads/2018/02/PaytoStudy-hover-min.jpg'" onmouseout="this.src='https://maceducationcanada.com/eric-content//uploads/2018/02/paytostudy-min.jpg'"></a></div>Basically it removes the onmouseover this.src and on mouseout this.src URLs
February 28, 2018 at 10:43 am #508161Tom
Lead DeveloperLead DeveloperCan you add the code to a pastebin and share it here?: https://pastebin.com/
February 28, 2018 at 10:46 am #508162Mary Pearson
This is what I would like it to be
February 28, 2018 at 10:48 am #508168Mary Pearson
without the extra // in front of uploads
February 28, 2018 at 10:19 pm #508527Tom
Lead DeveloperLead DeveloperAh yes – WordPress will always strip that kind of stuff out, as it can be dangerous.
More info in this thread, and a function which should “fix” it: https://core.trac.wordpress.org/ticket/27858#comment:25
March 1, 2018 at 8:00 am #508980Mary Pearson
Thanks Tom. I had tried another functions.php code (shown in my original post), but it didn’t work. Will give this new one a try. It looks like it’s more inclusive.
Thanks again!
March 1, 2018 at 8:42 pm #509361Tom
Lead DeveloperLead DeveloperNo problem 🙂
March 2, 2018 at 7:54 am #509777Mary Pearson
It works! Thanks again!
March 2, 2018 at 10:34 am #509894Tom
Lead DeveloperLead DeveloperYou’re welcome! 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.