How to change jQuery code to hide .jpg at the end of the url?

Can someone help me with this short piece of code? Right now, when I click a thumbnail on my site, it is creating a URL in the address bar. But url has .jpg at the end. How can I change the code so that it does not show .jpg at the end of the URL?

This part of the code also automatically opens the Colorbox image if the user enters a site with a URL, for example, www.domain.com/#image.jpg, so naturally, changing the code should also affect this.

Thanks!

jQuery(function() { var id, group; group = jQuery("a[rel='lightbox[63]']").colorbox({ onComplete: function() { window.location.hash = (this.pathname.match(/\/([^\/?#]+)$/i) || [,''])[1]; }, onClosed: function() { location.hash = ''; } }); id = location.hash.replace(/^\#/, ''); group.filter('[href$="'+id+'"]').eq(0).click(); }); 
+6
source share
1 answer

Replace this:

 window.location.hash = (this.pathname.match(/\/([^\/?#]+)$/i) || [,''])[1]; 

Wherein:

 // Get the image URL with_ext = (this.pathname.match(/\/([^\/?#]+)$/i) || [,''])[1]; // Get the image url without the extension without_ext = with_ext.substring(0, with_ext.lastIndexOf("."))); // Redirect window.location.hash = without_ext; 

Description

Example

http://jsbin.com/uqufev/1/edit

+1
source

All Articles