Title: Custom Expression and getTitle function
Last modified: August 20, 2016

---

# Custom Expression and getTitle function

 *  [Russell Jamieson](https://wordpress.org/support/users/powerblogservice/)
 * (@powerblogservice)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/custom-expression-and-gettitle-function/)
 * Please can you change the getTitle function so that it only applies to only one
   element rather all anchor elements with class fancybox.
 * The idea of the custom thumbnails expression is surely to make sure that the 
   function is only applied to the anchors selected by that expression.
 * My suggestion is that getTitle is redefined as follows (I dont think it will 
   break anything ;-):
 *     ```
       jQuery.fn.getTitle = function() {
               var title = jQuery(this).children("img") . attr("title");
               jQuery(this) . attr('title',title);
       }
       ```
   
 * With this approach I can use the image title attribute as a short title that 
   appears when the user places the cursor over the image and use a long title in
   the anchor title that contains a title, description, links etc.
 * I can then exclude my galleries from auto-lightboxing as follows:
 * `jQuery(thumbnails).not(".fancybox") . addClass("fancybox") . attr("rel","fancybox").
   getTitle();`
 * In other words – the expression says “make all images a fancybox that aren’t 
   already a fancybox’
 * Thanks in advance.
 * [http://wordpress.org/extend/plugins/fancybox-for-wordpress/](http://wordpress.org/extend/plugins/fancybox-for-wordpress/)

The topic ‘Custom Expression and getTitle function’ is closed to new replies.

 * ![](https://ps.w.org/fancybox-for-wordpress/assets/icon-256x256.jpg?rev=1864321)
 * [FancyBox for WordPress](https://wordpress.org/plugins/fancybox-for-wordpress/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/fancybox-for-wordpress/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/fancybox-for-wordpress/)
 * [Active Topics](https://wordpress.org/support/plugin/fancybox-for-wordpress/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/fancybox-for-wordpress/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/fancybox-for-wordpress/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [Russell Jamieson](https://wordpress.org/support/users/powerblogservice/)
 * Last activity: [13 years, 7 months ago](https://wordpress.org/support/topic/custom-expression-and-gettitle-function/)
 * Status: not resolved