Skip to main content
replaced http://drupal.stackexchange.com/ with https://drupal.stackexchange.com/
Source Link

The problem is that you are not using the Drupal API.

The CDN module needs to be able to alter the path from your Drupal site to your CDN. It does this by catching the URL via hook_file_url_alter(), and changing it.

The proper way to to make a URL in this case is with file_create_url(). Something like this should work

function MYTHEME_preprocess_page(&$variables) {
  $path = drupal_get_path('theme', 'MYTHEME');
  $variables['mysrc'] = file_create_url($path . '/images/v1/image1.jpg');
}

And then in your theme you would use

<a href="#"><img src="<?php print $mysrc; ?>" width="380" height="197" /></a>

However, as MołotMołot suggests, using a proper theme function to make a renderable image would probably be best.

The problem is that you are not using the Drupal API.

The CDN module needs to be able to alter the path from your Drupal site to your CDN. It does this by catching the URL via hook_file_url_alter(), and changing it.

The proper way to to make a URL in this case is with file_create_url(). Something like this should work

function MYTHEME_preprocess_page(&$variables) {
  $path = drupal_get_path('theme', 'MYTHEME');
  $variables['mysrc'] = file_create_url($path . '/images/v1/image1.jpg');
}

And then in your theme you would use

<a href="#"><img src="<?php print $mysrc; ?>" width="380" height="197" /></a>

However, as Mołot suggests, using a proper theme function to make a renderable image would probably be best.

The problem is that you are not using the Drupal API.

The CDN module needs to be able to alter the path from your Drupal site to your CDN. It does this by catching the URL via hook_file_url_alter(), and changing it.

The proper way to to make a URL in this case is with file_create_url(). Something like this should work

function MYTHEME_preprocess_page(&$variables) {
  $path = drupal_get_path('theme', 'MYTHEME');
  $variables['mysrc'] = file_create_url($path . '/images/v1/image1.jpg');
}

And then in your theme you would use

<a href="#"><img src="<?php print $mysrc; ?>" width="380" height="197" /></a>

However, as Mołot suggests, using a proper theme function to make a renderable image would probably be best.

Source Link
mpdonadio
  • 38.1k
  • 8
  • 89
  • 142

The problem is that you are not using the Drupal API.

The CDN module needs to be able to alter the path from your Drupal site to your CDN. It does this by catching the URL via hook_file_url_alter(), and changing it.

The proper way to to make a URL in this case is with file_create_url(). Something like this should work

function MYTHEME_preprocess_page(&$variables) {
  $path = drupal_get_path('theme', 'MYTHEME');
  $variables['mysrc'] = file_create_url($path . '/images/v1/image1.jpg');
}

And then in your theme you would use

<a href="#"><img src="<?php print $mysrc; ?>" width="380" height="197" /></a>

However, as Mołot suggests, using a proper theme function to make a renderable image would probably be best.