b2evolution b2evolution

  • Sign in
  • Sign up
  • About
  • Downloads
  • Hosting
  • Docs
  • Support
  • Sign in
  • Sign up
  • Manuals Home
  • Latest Updates
 
  1. b2evolution CMS User Manual
  2. Advanced Topics
  3. How to...
  4. Include an image rollover in a post

Include an image rollover in a post

In this page you will learn how to include rollover images in your posts. The final result will be an image that swaps to a different one when we rollover it.

Include an image rollover in a post
Original image
Image 1: Original image
Include an image rollover in a post
Image shown when the mouse is over it
Image 2: Image shown when the mouse is over it

This demo will show you the simple code behind this example.

Steps

Note: the step 1 might imply a security risk to your site. If you are administrator, our recomendation is to make these changes, publish your post and then switch back to the default values in the Blogging Permissions fieldset.

  1. In order to all this tutorial makes any sense, the XHTML Validation should be set to "Basic security checking", and the Security filter "Prevent javascript" must be disabled in the User Group of the user that will make the post. For more information, please read: Blogging Permissions Panel).
  2. Go to the Advanced Settings of the collection that you are editing, specifically to the fieldset Skin and Style Panel.
  3. Copy and paste the following code in the field Custom javascript section (before </body>):.

    
    <script type="text/javascript">
    $(function(){
       $('.swap').on('mouseenter mouseout', function(){
           var original = $(this).attr('src');
           var replacement = $(this).data('swap');
           $(this).attr('src', replacement).data('swap', original);
       });
    });
    </script>
    
  4. Add the Image 1 to your post by following the instructions on this page: How to Include External Photos or Images
  5. Swicth your editor to HTML view (if it wasn’t already).
  6. Add the following line to the <img tag, replacing the sample URL with the real URL of your Image 2

    
    data-swap="http://example.com/media/blogs/blog/image_roll_over_2.jpg?mtime=1406866079"
    
  7. The final code of the img tag should look like this:

    
    <img class="swap" src="http://example.com/media/blogs/blog/image_roll_over_1.jpg?mtime=1406866079" data-swap="http://example.com/media/blogs/blog/image_roll_over_2.jpg?mtime=1406866079" />
    
Created by mgsolipa • Last edit by fplanque on 2020-06-09 00:25 • •

No feedback yet

On this page

  • Steps

Search the Manual

Content Hierarchy

  • b2evolution CMS User Manual
  • User's Guide
  • Installation / Upgrade
  • Front-office Reference
  • Back-office Reference
  • Developer Reference
  • Operations Reference
  • Advanced Topics
    • Using Desktop Blogging Tools
    • Using Blogging Apps
    • Blogging by email
    • Using the APIs
    • Contributing
    • Translations (i18n/l10n)
    • Monetizing
    • How to...
      • How to create your own flag / locale
      • How to post by MMS
      • Make a Backup
      • How to use UTF-8
      • Use RSS
      • How to set up Google Analytics
      • How to compare backups
      • Publish an XML Site Map
      • Show images in my RSS when option "Post excerpts" is selected
      • Include an image rollover in a post
      • FTP 101: How to upload and manage files on your web server
    • Podcasting
  • Glossary
  • Archives
CMS software

This online manual is powered by b2evolution CMS – A complete engine for your website.

About b2evolution

  • What is it?
  • Features
  • Getting Started
  • Screenshots
  • Online demo
  • Testimonials
  • Design philosophy
  • Free & open source
  • Terms of service

Downloads

  • Latest releases
  • Skins
  • Plugins
  • Language packs

About us

  • About us
  • Contact

Webhosting Guide

  • Web hosting blog
  • Best web hosting
  • Cheap web hosting
  • Green web hosting
  • Hosting with SSH
  • VPS hosting
  • Dedicated servers
  • Reseller hosting
  • Int'l: UK / France

Docs & Support

  • Online manual
  • Forums
  • Hire a pro !

Other

  • Adsense
  • Press room
  • Privacy policy

Stay in touch

  • GitHub
  • Twitter
  • Facebook
  • LinkedIn
  • News blog
  • RSS feed
  • Atom feed

Founded & Maintained by François Planque