It bears mentioning that the 'path' and 'attributes' keys are required, while others are optional, according to coding standards.

Comments

pillarsdotnet’s picture

Status: Active » Needs review
dave reid’s picture

Are you sure attributes is required? I thought they'd load in the defaults if not provided?

pillarsdotnet’s picture

Failure to provide at least an empty array() results in a PHP notice.

From the code:


function theme_image($variables) {
  $attributes = $variables['attributes'];
  $attributes['src'] = file_create_url($variables['path']);

  foreach (array('width', 'height', 'alt', 'title') as $key) {

    if (isset($variables[$key])) {
      $attributes[$key] = $variables[$key];
    }
  }

  return '<img' . drupal_attributes($attributes) . ' />';
}

That first line will result in an "Undefined index" notice.

dave reid’s picture

@pillarsdotnet: Prove to me that doing theme('image', array('path' => 'pathtofile.png')); causes a problem and that the theme system fails to merge in the default attributes variable of an empty array?

pillarsdotnet’s picture

StatusFileSize
new1.46 KB

@Dave Reid -- does the function require attributes or does it not?
And if the function is "for internal use only; module developers must not use" then the documentation should say so.

dave reid’s picture

Status: Needs review » Closed (works as designed)

Please read this thread http://drupal.org/node/1001990 - the function already links to http://api.drupal.org/api/drupal/modules--system--theme.api.php/group/th... which explains that it is internal only. There is nothing to fix here.

pillarsdotnet’s picture

Thanks for the education. I've followed up on all the other issues I posted; you don't have to clean up behind me anymore... :)