jQuery script for swapping images on hover/rollover on Drupal 7 + Views


I tried to find the way to make do the rollover image using Views but after searching and looking into many websites, it doesn't seem to have clear the instruction how to do it.  So, here is what I did to make it work. First of all, you need to download and install Image URL Formatter here -> http://drupal.org/project/image_url_formatter

1. Create a new content with 2 image fields. The Regular image field and a Rollover image field.

2. Create a new view. In the FIELDS, add Rollover image field first, follow by Regular image field.

3. Configure Rollover image field

  • Check on "Exclude from display"
  • Set Formatter as Image URL

Rollover Image Setting Screen Capture
3. Configure Rollover image field

4. 3. Configure Regular image field as below :

  • Set Formatter as Image URL
  • Check on Rewrite the output of this field
  • Type below HTML into the text box
<img src="[field_regular_image]" rel="[field_rollover_image]" class="rollover" />

Regular Image Setting Screen Capture
4. Configure Regular image field
4. Configure Regular image field

5. Now, save your views.  Then, you have to create a JS file to make it work. Let's created it in your theme directory. I use Zeropoint Theme, so, I create rollover.js in _custom folder under Zeropoint directory :

rollover.js file location

6. in rollover.js, paste the code below into it :

(function ($) {

$(document).ready(function() {
//rollover swap images with rel 
  var img_src = "";
  var new_src = "";
      img_src = $(this).attr('src'); //grab original image
      new_src = $(this).attr('rel'); //grab rollover image
      $(this).attr('src', new_src); //swap images
      $(this).attr('rel', img_src); //swap images
      //mouse out
      $(this).attr('src', img_src); //swap images
      $(this).attr('rel', new_src); //swap images
  //preload images
    var cache = new Array();
    //cycle through all rollover elements and add rollover img src to cache array
      var cacheImage = document.createElement('img');
      cacheImage.src = $(this).attr('rel');


7.  Now, edit "zeropoint.info" to load rollover.js. Just add below line into the file :

scripts[] = /_custom/rollover.js

It will look like below image :


That's it.  Now, test your rollover image. It should work the way we want it to be.


Software Tested :

  • Drupal 7.18
  • Views 7.x-3.5
  • Image URL Formatter 7.x-1.0


Source :

  • http://grasmash.com/article/simple-jquery-script-swapping-images-hoverrollover


Usually I never comment on blogs but your article is so convincing that I never stop myself to say something about it. You are doing a great job Man. keep it up. Here am also tried something. You may check it.

Привет друзья!
Предлагаем Вашему вниманию изделия из стекла для дома и офиса. Наша организация работает 10 лет на рынке этой продукции в Беларуси. Изготовим для вас и установим душевую кабину из стекла на заказ. Профессиональные замерщики и монтажники. Мы используем различные типы материалов и фурнитуры для создания душевых кабин и душевых перегородок любого дизайна и конструкции, устанавливаем на поддоны или без поддонов. У нас вы сможете заказать стекло для душевой кабины по индивидуальным размерам и проекту. Выполним доставку изделия и его монтаж.
Более подробная информация размещена https://drive.google.com/file/d/13CAPanRKgpkKCcaHzI0EiaMtWM0saPJO/view?u...

In this male ruling world, a ton of ladies have good thoughts and a little wish to go into business. For some ladies it simply remains as https://www.stuffroots.com Planning to switch your telephone? This is actually an energizing and bright thing. Yet, kindly remember the significant information put away on the old telephone.

Extraordinary compared to other tip I can give you is that you Trust is one of the fundamental business resources. On the off chance that you https://www.stuffroots.com expect to improve the change rates, maybe you should begin by upgrading your image trust. As Steve Forbes says, "Your image is the absolute most significant speculation you can make in your business.

For the single mother, it is very difficult to live single and develop a kid and live happily. Struggling between job and kid make the mother mentally and emotionally stressed.<a href="https://www.trendsnbest.com/free-cars-for-single-moms/">cars for single moms</a>
Just how single mothers help with getting a car on that covered the different important topic for the single mother in need of a vehicle.

This is a great blog. It very reliable for new readers. It really makes me happy. Thanks for sharing it. I am a gamer and here is something interesting for you. You may check this https://bit.ly/3uFha9q

berbagai permainan di web. Kami akan memeriksa lebih banyak ruang online dan hasilnya di artikel. Ikuti artikel untuk mendapatkan data poin demi poin. Kami secara keseluruhan menyadari bahwa pembukaan adalah sebuah mesin. Dengan asumsi kami menggambarkan klub perjudian konvensional, mesin permainan ditemukan dengan hati dan lebih dari tiga atau empat gulungan bergerak lurus. Gulungan

This is extremely helpful info!! for gamers Very good work. Everything is very interesting to learn and easy to understand. Take the given information. Hi, my name is Johny dekar, and I am gaming smith. I play a game called Minecraft. and having site about how to edit a Minecraft skin https://erickaweber60.doodlekit.com/blog/entry/10978554/how-to-edit-a-mi...

I'm glad I found this web site, I couldn't find any knowledge on this matter prior to. Also operate a site and if you are ever interested in doing some visitor writing for me if possible feel free to let me know, i am always look for people to check out my web site. https://www.blurb.com/user/Rstarck?profile_preview=true white page

I have just gone through your website and I am highly convinced that you can offer quality <a href="https://www.economicshomeworkhelper.com/">economics homework help</a>. I have seen several
samples and the quality looks good. If the samples are done by you then I am more than willing to hire you for my assignment. I just hope that anytime I contact you for an<a href="https://www.economicshomeworkhelper.com/">economics homework help</a> you will be available to help because some of these assignments are always very urgent.

I have a ledger posting assignment involving several entries. I am currently fishing for the best <a href="https://www.accountingassignmenthelper.com/">Accounting Homework Help</a> tutor to help me with the task and from what I have read, you guys don’t seem too bad at your job except for the few flaws. I may consider taking <a href="https://www.accountingassignmenthelper.com/tutors/">Accounting Assignment Help</a> from here and hopefully I will be back with positive feedback.

I am happy that many students have received the right <a href="https://www.mathsassignmenthelp.com/experts/">Math assignment help</a> through you. I am in my third year in college and I have not had a chance to get such help. Since I have come across your post, I hope I will find the right <a href="https://www.mathsassignmenthelp.com/">Math homework help</a> through you. My only obstacle would be finances. I hope that you are pocket friendly or should I call it student-friendly

This is very great and helpful information. This is very helpful for newcomers. Thanks for sharing this great article. I am a gamer and I would like to suggest to you an auto-clicker which is really interesting. You may visit here https://hardleynenon.wixsite.com/gamerspoint/post/5tipdantrikyangakanmem...

Thank you for posting such a great article! I found your website perfect essay writing service of needs. It contains wonderful and helpful posts. Keep up the good work !. Thank you for this wonderful Article! And also for great content about <a href= "https://mypaper.pchome.com.tw/skindex"> Minecraft skins </a>

Other than considers school additionally have may extracurricular exercises like games, social exercises, and so forth Gidda and https://www.ashrayliving.com/pg-near-kamla-nagar Bhangra of this College are popular and practically on each young fest, our school got numerous honors.

Your blog is fantastic. It really makes me happy and also reliable to read for new readers. Thanks for this great blog. I am a gamer and I would like to suggest to you an auto-clicker which is really interesting. You may visit here https://www.deviantart.com/incrementalgamers/journal/Bakit-ginagamit-ng-...

Your <a href="https://www.statisticsassignmentexperts.com/">Statistics Assignment Help</a> team did an amazing job on my STATA homework. In Fact I would like to know th<a href="https://www.statisticsassignmentexperts.com/blog.html">Statistics Homework Help</a> expert who handled my work because I would like to hire them again. I am pleased with everything about you.

Having gone through your website I am sure that you are good enough. I have checked two of your samples and I like the work already. I want to get an A in my international economics and I believe you are the right <a href="https://www.economicshomeworkhelper.com/microeconomics-assignment/
">economics assignment help</a> expert to guide me in that. If I get an A in this first one then you will be my permanent help<a href="https://www.economicshomeworkhelper.com/">economics homework help</a>, expert.

Your post has opened my eyes. I have never thought of asking for <a href="https://www.mathsassignmenthelp.com/experts/">Math assignment help</a> but I will try you. It would be a good thing to have someone ready to provide <a href="https://www.mathsassignmenthelp.com/">Math homework help</a>. Sometimes I spend sleepless nights solving my assignments. If I knew you, I would not spend much time since I would just send you the assignments with a guarantee of top grades.

How do I know that you are offering the best <a href="https://www.accountingassignmenthelper.com/tutors/">Accounting Assignment Help</a>? I have worked with more platforms in the past and I have had a lot of disappointments. I would be happy if you offered me <a href="https://www.accountingassignmenthelper.com/">Accounting Homework Help</a> samples so that I can see the quality of work I should expect from you. If you satisfy me in the first task, then I am going to hire you for more work.

This article is really great. It inspire me lot, it really makes me happy. Thanks for this great article. I am a gamer and I would like to suggest to you an Auto-clicker which is really interesting. You may visit here https://clickerslegacy.puzl.com/

I like your article very much. This is really great information and easy to understand. I am a gamer and I would like to suggest to you an Auto-clicker which is really interesting. You may visit here https://clickerx.nicepage.io/Home.html?version=62310d7a-3e0a-4dcf-b55e-e...

This is a very good blog. I appreciate your work. I found so many interesting stuff in your blog. Really its great article. Keep it up. visit my article about Auto-Clicker For that Click on given link

Доброго вечера!!!

Информативный ресурс https://ostrovtepla.ru/ . Советую!
Удачи всем!

This is extremely helpful info!! for gamers Very good work. Everything is very interesting to learn and easy to understand. I would like to suggest to you an Auto-clicker which is really interesting for that Click on given link

This is extremely helpful info! . I appreciate your work. Really its great article. I am a Gamer and I would like to suggest to you an Article about OP Auto Clicker which is really interesting for that Click on given Link

The sign test is a non-parametric test that is used to compare the sizes of two groups. By a parametric test, we mean that it does not assume that the sample came from a particular distribution. This test, like any other test, can be done using statistical software. That is why I need a <a href="https://www.statisticsassignmentexperts.com/blog.html">Statistics Homework Help</a> expert to help know how to conduct the sign test in STATA. Lastly, does your <a href="https://www.statisticsassignmentexperts.com/">Statistics Assignment Help</a> experts offer online classes?

I experienced the most straightforward and fast order placement process on <a href="https://www.matlabassignmentexperts.com/">Matlab Assignment Help</a> website. Their competent customer care representatives took me through the process faster and easier. I loved the fast site with the easy system. I must also thank them for their plagiarism-free answers built from the ground. They navigation must be having the world's best <a href="https://www.matlabassignmentexperts.com/matlab-experts.html">Matlab homework help</a> experts.

With the experience you have stated, I believe you are the person I was looking for. The results I got in my last semester were so disappointing. I wanted a <a href="https://www.mathsassignmenthelp.com/">Math homework help</a> expert to help me get better results and since you are here, I believe I will rely on you. Kindly tell me how much you charge for <a href="https://www.mathsassignmenthelp.com/experts/">Math assignment help</a> or what you consider when charging people.

Most of the <a href="https://www.nursingassignmenthelp.com/experts/">Nursing Assignment Help</a> experts I have worked with, do not keep time. I have had a lot of disappointments in the past when a tutor fails to submit my work on time yet I have paid. What do you do differently from others and how am I going to be sure that you will deliver my work on time. I am afraid of asking for <a href="https://www.nursingassignmenthelp.com/">Nursing Homework Help</a> only to be disappointed again.

Buy WordPress themes From TemplateTrip. All templates are SEO optimize come with extensive features and one click installer.
The biggest collection of HTML templates, WordPress and ecommerce themes, web graphics and elements online. TemplateTrip offers web design products developed by professionals from all over the world.

I like this article very much. It really makes me happy. It is very helpful for newcomers. Thanks for this great blog. I am a gamer and I would like to suggest to you an OP Auto clicker which is really interesting. You may visit here http://forloveofgame.simplesite.com/449377692

Thanks for this post online jQuery script for swapping images on hover/rollover on Drupal .

I appreciate your work. I found so many interesting stuff in your blog especially its discussion. Really its great article. Keep it up. am the gamer one and visit several site for gaming update out of that here is the 1 site which gives good gaming content for that Visit site

Thank you for this site . very informative post, and I love it am a musician and having site about who teach us about How To Download Optifine In Minecraft. if you want you can check it. https://www.evernote.com/shard/s532/sh/2eca624b-1a77-7eb4-0960-d09b542c8...

She finished MBBS from the lofty University of Ghorakpur in 1989 and MS - Obstetrics and Gynecology from University of Gorakphur in 1993. she has insight of 32 years of in these fields. She is known among her patients to be a decent audience and a gynecologist who works in female regenerative wellbeing including incorporates the uterus, fallopian tubes, pregnancy, labor, the post pregnancy time frame, and ovaries and breasts.Haicure https://haicure.com/best-gynaecologist-in-mira-road.php
Gynecology Clinic in Mira street gives total ladies medical care by woman gynecologist in Mira street, start from meeting with the best gynecologist to blood examinations, normal test, all through therapy and aftercare support administrations. We unequivocally accept to put resources into clinical development to permitting our Gynecologist to perform best as women expert specialist in Mira street.


Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.