Is it possible to call this module's theme function from a template file to automatically resize a site logo instead of content images?

Thanks,
-mike

Comments

frazras’s picture

What are the alternative methods to accomplish the above? For even other non-fielded images

frazras’s picture

Category: support » feature

I simply created a node using the adaptive image module then copied the HTML it used and pasted it in my theme

<img class="adaptive-image" typeof="foaf:Image" src="<URL>/sites/default/files/styles/618x326/adaptive-image/public/field/image/logo.png" alt="">

It could be a bit more elegant. Maybe this module should try and address that using this same idea.

chefnelone’s picture

I also think it's a good idea to implement this feature.

tmsimont’s picture

Although this would be an awesome feature, this isn't so straightforward to implement into this module.

This is because of a limitation of theme_image_style()

This function does not work with images outside the files directory nor with remotely hosted images.

The logo is in the theme folder, so unless that core image function is adjusted to work with theme images, this is a no go.

However, if you want to just drop your logo into the root of the public files directory you can use code like this:



  $site_name = filter_xss_admin(variable_get('site_name', 'Drupal'));

  
  $image = array(
    '#theme' => 'image_style',
    '#path' => 'public://logo.png',
    '#style_name' => 'leading',
    '#alt' => t('!site_name logo', array(
      '!site_name' => $site_name,
    ))
  );

  return l(render($image), '<front>', array(
    'html' => TRUE,
    'attributes' => array(
      'id' => 'logo',
      'rel' => 'home',
      'title' => t('Return to the !site_name home page', array(
        '!site_name' => $site_name,
      )),
    ),
  ));

I'm using that in template php in a hook that overrides how the module "Blockify" renders the logo block.

Note that I'm using an image style called "leading" and my logo is right in the root of the public files directory, and is named "logo.png"

n1k’s picture

Status: Active » Closed (won't fix)

For now use the Workaround. Can't implement this yet (#4).