When an image is linked to its node (rather than the original image or some imagecache preset), the link to the node is improperly rewritten to use the CDN. This was introduced in http://drupalcode.org/project/cdn.git/commit/6dde0e1 which was a fix for issue 1165404.

Comments

pdrake’s picture

Status: Active » Needs review
StatusFileSize
new2 KB

This patch adds an option that checks to ensure the link file name matches the image file name before rewriting it to use CDN.

pdrake’s picture

StatusFileSize
new2.18 KB

This patch is the same as above but adds a missing @param comment.

elliotttf’s picture

Status: Needs review » Reviewed & tested by the community

The patch in #2 is working perfectly for me.

wim leers’s picture

Status: Reviewed & tested by the community » Needs work
StatusFileSize
new2.33 KB

Thank you very much!

I tested it, and unfortunately it breaks another scenario, e.g. the one on wimleers.com. It looks like this:
<a href="//cdn/files/image.png"><img src="//cdn/files/resize/image-420x69.png"></a>
I.e., the filenames do not perfectly match (because the thumbnail image is resized using the Image Resize Filter), but it's *still a file*.

Proposed solution: compare the file extensions instead of the file paths.

I also just merged #1557948: When using wildcard CDN mapping: image links always point to the CDN, even when not linking to an image but to an HTML page with this one.

wim leers’s picture

Status: Needs work » Needs review
StatusFileSize
new2.34 KB

And here's a patch that does just that. Also fixed a critical bug in it: the return statement should've been a continue statement…

elliotttf’s picture

Status: Needs review » Reviewed & tested by the community

This also works for me and looks good. +1

wim leers’s picture

I'd like @pdrake's approval as well :)

damienmckenna’s picture

+1, patch #5 works for me too. Also: grrrr.

damienmckenna’s picture

Priority: Normal » Major

Bumping this to Major as it, to all intents and purposes, breaks your site.

pdrake’s picture

Priority: Major » Normal

#5 works for me - I would mark this RTBC if it wasn't already.

pdrake’s picture

Priority: Normal » Major

Apparently, DamienMcKenna and I were updating at the same time - putting this back to Major as I agree with that priority.

damienmckenna’s picture

FYI, here are the settings I was using that triggered the problem on our site:

$conf['cdn_advanced_pid_file'] = '';
$conf['cdn_advanced_synced_files_db'] = '';
$conf['cdn_basic_mapping'] = 'http://somethingorother.cloudfront.net';
$conf['cdn_farfuture_status'] = 0;
$conf['cdn_farfuture_unique_identifier_mapping'] = "misc/*:modules/*:themes/*|drupal_version\nsites/*|mtime\nsites/*|.avi .m4v .mov .mp4 .wmv .flv|perpetual";
$conf['cdn_mode'] = 'basic';
$conf['cdn_reverse_proxy_test'] = 0;
$conf['cdn_stats'] = 0;
$conf['cdn_status'] = '2';
wim leers’s picture

Thanks, will commit very soon, backport and do new releases.

wim leers’s picture

Title: links to drupal nodes are rewritten to CDN » Only rewrite image links when they have the same file extension as the image's
Assigned: Unassigned » wim leers
Status: Reviewed & tested by the community » Fixed
mrsimonelliott’s picture

dev version fixed this for me, thanks

mile23’s picture

Version: 6.x-2.x-dev » 7.x-2.5
Status: Fixed » Active

This is a problem for 7.x-2.5, as well.

Images set to link to content end up sending the browser to cloudfront.

damienmckenna’s picture

Version: 7.x-2.5 » 6.x-2.x-dev
Status: Active » Fixed

@Mile23: This has been fixed and is available via the -dev downloads, otherwise just wait for the next release.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

wim leers’s picture

This now has test coverage thanks to #1929918: Test coverage for image URL rewriting.

dan.mantyla’s picture

Yup, just discovered my sites are now directing users to 234fs452fd5.cloudfront.net/my/site and users are like "am I getting phished??"

Thanks for fixing this!!

I'm using 7.x-2.5, this has been patched in 7.x-2.x-dev as well as 6?

I would suggest that [6|7].x-2.6 be released ASAP, as it is a major bug, but now with the latest security release to Drupal core, 7.20, the CDN module has much more work ahead of it... Great module though! I hope to contribute soon.

wim leers’s picture

I'm using 7.x-2.5, this has been patched in 7.x-2.x-dev as well as 6?

Correct.

I would suggest that [6|7].x-2.6 be released ASAP, […]

Working on that: #1915662: [meta] 2.6 release (bugfixes only). :)

I hope to contribute soon.

Great! :)