I just set up two links on one of my WordPress sites to test this. I used the latest version of the dwi.php file I sent you, and tested it both in debug mode and in normal mode. One link connected to a wp-content/uploads folder, the other was to a /test/portfolio folder outside of WordPress’ file structure like your /large folder. Both used the same image. The WordPress portion of the .htaccess is identical to the one you showed me above.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Both links worked in both debug mode and normal mode. I didn’t get any errors. I also tested with the target attribute of the links set to “_blank” to see if that would make a difference. That works too, but of course it pops up a new tab briefly, then the new tab goes away once the download dialog pops up.
The differences between the site I tested it on and yours are your theme and all its code, and your server configuration. Included in your theme is that we’re attempting to use the links within fancybox. So I think the testing pretty much rules out something already in your .htaccess, and those 500 errors I see with Firebug and the extra “/” must be coming from elsewhere.
Maybe we do need to drop back to the .htaccess method. If you put an .htaccess in the /large/portfolio folder to force download of images, as long as all the images you want to force the download for are in there, or you put a similar .htaccess in all the folders where you want to force the download, maybe that will work. I think I mentioned this earlier, but discarded it because it meant you had to mess with the .htaccess in all the affected folders.
You can test it by putting the following in an .htaccess in the /large/portfolio folder and then just creating a hyperlink to a test image;
SetEnvIf Request_URI "([^/]+\.jpg)$" REQUESTED_IMAGE_BASENAME=$1
SetEnvIf Request_URI "([^/]+\.png)$" REQUESTED_IMAGE_BASENAME=$1
Header set Content-Disposition "attachment; filename=\"%{REQUESTED_IMAGE_BASENAME}e\"" env=REQUESTED_IMAGE_BASENAME
If just setting the Content-Disposition to “attachment” doesn’t do it, you can also try setting the type to “octet/stream,” but I think this should work. You don’t have to worry about restricting it to a specific folder if you put the .htaccess in the specific folder instead of the root directory; it should affect the current folder and all subfolders.
Your hyperlink code would change back to:
<a class="saveimage-icon" href="<?php echo get_post_meta($post->ID,'largeimage',true); ?>">Download <?php the_title(); ?></a>