icylogic / carbon

A blazing slow hexo theme
MIT License
48 stars 12 forks source link

fancybox does not work #22

Closed huangxjian closed 8 years ago

huangxjian commented 8 years ago

Hi,fancybox does not work in this theme,but it worked when I changed another theme.Can you fix this problem , I love this clean and simple theme very much.

icylogic commented 8 years ago

Thanks. It works properly in my local tests. Could you provide details and/or your website?

huangxjian commented 8 years ago

Sorry,forgot to tell you .It works properly after I add the following script to the scripts folder.

var rUrl = /((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[.\!\/\\w]*))?)/;

/**
* Fancybox tag
*
* Syntax:
*   {% fancybox /path/to/image [/path/to/thumbnail] [title] %}
*/

hexo.extend.tag.register('gallery-img', function(args){
  var original = args.shift(),
    thumbnail = '';

  if (args.length && rUrl.test(args[0])){
    thumbnail = args.shift();
  }

  var title = args.join(' ');

  return '<a class="gallery-img" href="' + original + '" title="' + title + '">' +
    '<img src="' + ( original) + '" alt="' + title + '">'
    '</a>' +
    (title ? '<span class="caption">' + title + '</span>' : '');
});