I'm sure someone must have come across this issue, but I can't find any mention of it around.

In the theme layer I have a div with social icons in. They're declared in page.tpl.php all straightforwardly:

img src="sites/all/themes/crisp_red/images/twitter.png"

And they work as expected in Views or static or manually aliased content, but the images break on nodes Pathauto has aliased nodes. When I look I can see a request being made for this image:

http://mysite.com/content/sites/all/themes/crisp_red/images/youtube.png

Can I stop Pathauto rewriting links to the theme directory?

I know could fix this by linking to an absolute path in the theme layer, but I'm developing this locally in a subdirectory whereas the live site is in the document root, so that's not a great solution. Pathauto's such a well used module I feel like there must be a neater way of doing this - is there a better solution I'm missing?

Comments

kwerey’s picture

Issue summary: View changes
kwerey’s picture

Issue summary: View changes
kwerey’s picture

In case anyone else comes across this, I went and found out that drupal_get_path is a thing, so you can do this:

<a href="http://www.pinterest.com/workplace-social-media"><img src="<?php print drupal_get_path('theme', 'crisp_red') . '/images/pinterest.png' ?> "></a>

ben.kyriakou’s picture

Status: Active » Fixed

Hi kwerey. It looks like you've solved this one so I'm going to mark this as Fixed, but feel free to move this back to Active if you have any more questions.

If you'd like to go further down the rabbit hole I'd also recommend looking at using the l() and url() function to generate links and urls in Drupal. These will give you additional benefits, such as automatic aliasing of internal URLs when using a module like Pathauto to generate human-readable aliases.

Status: Fixed » Closed (fixed)

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