Okay, some progress.
If I leave the anchor tag in its present generic state
<a href="#" ...
it won’t return anything at all, since it can’t tell the javascript what image to look for.
If I use the same snippet of code that sends the proper source location to the image tag, and configure the template file’s anchor tag like so:
<a href="<?php echo $image['url']; ?>" ...
it doesn’t work; doing so returns this in the page source:
<a href="" class="dummy" rel="lightbox"> <img src="https://the/proper/path.jpg" alt="" />
I don’t know why it sends the right path to the image tag and sends nothing to the anchor tag.
If I simply paste the actual image path into the template file, it works fine. So the problem is configuring the anchor tag to have the proper path to the image.
You wrote above that using custom fields will work only if you add the rel attribute. I’ve done that; the problem is the path. How do other users get around this problem when they’re using images loaded via a custom field?