0

I have fancybox working fine on my localhost setup, when using a href tag like this:

<a href="http://localhost/wordpress/wp-content/uploads/2014/10/example.jpg" rel="gallery"></a>

however, when I use code such as this:

<a href="./download/file.php?id=529" rel="gallery"></a>

fancybox doesn't pop up it just loads the image over the existing page.

I'm using phpbb, and I want to be able to click an attached image on the forum and for it to open with fancybox. All phpbb file attachments are saved into the 'files' folder of phpbb with a randomized name and without an extension (for security purposes.)

If anybody could point me in the right direction i'd be very grateful! :)

James R
  • 3
  • 2
  • Are you sure fancybox is loaded on your page? Do you have any errors in your console? – Jerodev Nov 18 '14 at 14:43
  • Sorry yes, I did a test just to check that, and replaced the file.php src with a standard image.jpg. and the fancybox is working fine, it just doesn't like the file.php! – James R Nov 18 '14 at 14:44

1 Answers1

0

Try adding &.jpg to your url. So that it becomes ./download/file.php?id=529&.jpg.

I have had this problem before with another lightbox plugin.

Jerodev
  • 32,252
  • 11
  • 87
  • 108
  • Oh, perfect! I've just tested it in Chrome and it worked, so thanks for that! Did you experience any bugginess or cross browser issues when you implemented this yourself? Additionally, why does that work? I did try to vote for your answer, but I don't have enough reputation points :( – James R Nov 18 '14 at 14:55
  • That is because most lightboxes search for anchor tags ending in `.jpg`, `.png`, etc. to make sure that those are images files. By adding `.jpg`, you let fancybox think that this is an image file. It should work in all browsers because it is the fancybox plugin that you are fooling. You can always mark this as the answer to your question. ;) – Jerodev Nov 18 '14 at 15:01
  • Yep, it worked in (IE, Chrome, Firefox, Safari, Opera). Oh I see, good job :) I've just thought of the only potential stumbling block, and that is, the available attachment types are for example... jpeg, jpg, gif, png ... however I'm sure i'll figure it out! Thanks for your help, have a good day! – James R Nov 18 '14 at 15:06
  • You can always add `&.jpg`, it doesn't matter what extension the actual file is. It doesn't change anything to the `file.php`. – Jerodev Nov 18 '14 at 15:13
  • Oh okay, i'm with you I just tested that haha. So it is just purely to trick fancybox. Cheers Jerodev – James R Nov 18 '14 at 15:18