jQuery Mouseover for Inline Images

January 13, 2010 · Posted in Web Stuff · Comment 

I was hoping to find a WordPress plugin for creating a mouseover or hover effect on an image that is not a hyperlink, but none is available. So what I wanted is for my client to be able to post an image on a page and in a simple way, swap the image onmouseover.

Here is what I did, when inserting an image into the web page I give it the class “swapper” and ame the mouseout or default state of the image -OFF:

<img class="swapper" src="http://xyz.com/coffee-OFF.jpg" />

Then the jQuery function to do the swapping:
<script>
$(document).ready(function(){
// do this on hover for images with the class swapper
$("img.swapper").hover(function() {
//Get the src attribute of the default image
rollSRC = $(this).attr("src");
//Replace -OFF with -OVER for the rollover version
rollOVER = rollSRC.replace('-OFF', '-OVER');
$(this).attr("src", rollOVER );
}, function() {
//revert to the original image
$(this).attr("src", rollSRC );
});
});
</script>

If you are using this on WordPress change all the $ signs to jQuery (eg jQuery(document).ready(function()...)

Now I should be able to explain to the client that they need to:

  1. Upload the two image states coffee-OFF.jpg and coffee-OVER.jpg into the same folder (case sensitive)
  2. Insert the default image with the class=”swapper”

So Simple how can it go wrong!

Of course I did not come up with this entirely on my own, the following articles all helped me:

http://www.atlantajones.com/web-dev/even-easier-jquery-rollovers/

http://bavotasan.com/tutorials/a-simple-mouseover-hover-effect-with-jquery/

http://www.frodesigns.com/2009/07/wordpress-jquery-image-rollovers/

WordPress: Webform / Contact form Plugins Compared

October 12, 2009 · Posted in Content Management System · 2 Comments 

As with most WordPress plugins, it is a bit of a nightmare trying to find the right one. Something I really struggled with is getting a form plugin that works. First prize would be if the core of WP contained form handling as is now happening with Drupal 7, but…

Contact Form 7

I started off here after reading extensive review of various plugins in the WP directory I thought this was the best one.

http://wordpress.org/extend/plugins/contact-form-7/

On the plus side; it is pretty simple and easy to configure, you define your form on the back-end and then call your form using some comment text.

Where I ran into issues was the following:

  • It is built as a contact us form and that is all
  • No saving to database
  • No way of inserting custom variables

My last point was the straw that broke the camel’s back; I needed a select dropdown which I wanted to select the user’s country. To be clever I was determining their country using their IP number (More Here). But there was no way to A. dynamically populate the field or B. dynamically preselect a value.

cForms II

This plugin is GPL but for some reason it is not in the WP repository, but it is EXCELLENT!

http://www.deliciousdays.com/cforms-plugin/

Not only could I achieve the above things I could not using CF7, but there are some awesome features in addition, which I have since started using. It really is a forms plugin rather than just a contact us form.

  • Can enhance the standard comments fields
  • Allows you to define a cForms form in PHP by setting arrays and calling a function.
  • Still simple to configure a simple form if that is all you need.
  • Refer a friend form field types.
  • Form fill in autoresponders with an optional attachment (HTML and Text)

What really sold it to me? I asked a question on the forum and I got help the next day. (search the forum first else he might bite your head off for asking silly questions :-) )

Any other experiences folks is there a better WP forms plugin out there?

How many plugins does it take to get a working site?

July 29, 2009 · Posted in Content Management System · 1 Comment 

Well I know that my most recent post was going on about the problems with WordPress plugins, and there being 10 versions of any one plugin rather than the dev community working together to make one good plugin.

Well this post is to gripe about the number of Drupal plugins it takes to get a workable website. honestly on my WordPress site I have 7 plugins, each addressing a specific need. On Drupal, a site with a blog and pages? 18 plugins, and I am not counting core or even core optional modules. Really if you are just wanting a CMS use WordPress or Joomla or something simpler.

Why use Drupal? Couple of killer plugins, and FLEXIBILITY.

WordPress: plugin hell

July 22, 2009 · Posted in Content Management System · Comment 

So I am pretty new to WordPress, but my first impressions chronologically were:

  1. “wow this is really simple to use” – WYSIWYG editor, image insertion all there (I do a lot of Drupal)
  2. “Pages can not get categorised!!??!!??” – Bump into limitations
  3. there are multiple of each plugin, why can’t these people work together?

My last one is pretty important, and affects Joomla too; if all the plugin builders working on Amazon plugins worked together there would be an amazing plugin, except all these people are in it for personal gain and adulation? so it looks like a bunch of kids fighting over a toy and all saying mine, mine mine. (I see this every day, my daughter is 2yrs old :-)

WordPress – IP to Nation or Country Plugin

July 22, 2009 · Posted in Content Management System · Comment 

I love getting something right and it is really satisfying when someone provides their code GPL’d. I just use the IP to Nation WordPress Plugin to do the following on a client’s site:

  1. Display a country flag of the visitor’s detected country
  2. Display a link to country specific information if the user is from one of the focus countries.
  3. Prepopulate the country dropdown of the contact us form.

And I really do not need to explain how I did this because the documentation here is pretty good.

Sometimes I am not moaning
:)