img_assist is working OK for me, but when the image is inserted, it includes HTML tags that I don't want.

I don't want it to make me have the caption in strong tags.

Can anyone tell me where this code is generated and if it is possible to edit it?

Comments

elfur’s picture

This is a themeable function, so what you can do, is copy the code of that function into the template.php file you have in your theme folder (if you have no template file like that, just create it, it's used for those exact things)

the code that you need to change is included here below:

change the following lines:

First, change the name of the function, replace 'theme' with the name of the theme you're using (i.e. bluemarine, if you're using that theme)

function theme_img_assist_inline($node, $size, $attributes) {

Next, change the lines where the caption is defined (remove the strong tags):

    $caption = '<strong>' . $attributes['title'] . ': </strong>' . $attributes['desc'];
  } elseif ($attributes['title']) {
    $caption = '<strong>' . $attributes['title'] . '</strong>';

And you're done :)

The original function:

function theme_img_assist_inline($node, $size, $attributes) {

  if ($attributes['title'] && $attributes['desc']) {
    $caption = '<strong>' . $attributes['title'] . ': </strong>' . $attributes['desc'];
  } elseif ($attributes['title']) {
    $caption = '<strong>' . $attributes['title'] . '</strong>';
  }
  $node->title = strip_tags($caption); // change the node title because img_assist_display() uses the node title for alt and title
  $img_tag = img_assist_display($node, $size);

  $output  = "<span class=\"inline {$attributes['align']}\">";
  $link = explode(',', $attributes['link']);

  if ($link[0] == 'node') {
    $output .= l($img_tag, "node/" . $node->nid, array(), NULL, NULL, FALSE, TRUE);

  } elseif ($link[0] == 'popup') {
    $popup_size = variable_get('img_assist_popup_label', 'preview');
    $info = image_get_info(file_create_path($node->images[$popup_size]));
    $width = $info['width'];
    $height = $info['height'];
    $output .= l($img_tag, '', array('onclick'=>"launch_popup($node->nid, $width, $height); return false;", 'target'=>'_blank'), NULL, NULL, FALSE, TRUE);

  } elseif ($link[0] == 'url') {
    $output .= l($img_tag, $link[1], array(), NULL, NULL, FALSE, TRUE);
  } else {
    $output .= $img_tag;
  }

  if ($caption) {
    $info = image_get_info(file_create_path($node->images[$size['label']]));
    $width = $info['width'] - 2; // reduce the caption width slightly so the variable width of the text doesn't ever exceed the image width
    $output .= "<span class=\"caption\" style=\"width: {$width}px;\">$caption</span>";
  }
  $output .= "</span>";
  return $output;
}

HTH
/elfur.is

Minty’s picture

Now I can modify the output to give me the really clean code that I want with all styling issues dealt with in .css.

Not only that, but I can see that template.php will be useful in other areas.

Drupal really has a long learning curve, but it's worth it, and help like this in the forums is really appreciated!