Ticket #596 (assigned defect)

Opened 3 years ago

Last modified 2 years ago

Captions issue

Reported by: benj Owned by: jim
Priority: minor Milestone: Maintenance
Component: Theme Keywords:
Cc: ed, benj, ben Estimated Number of Hours: 0.0
Add Hours to Ticket: 0 Billable?: yes
Total Hours: 0

Description

basically captions are appearing on body inline images and featured images on STG but not PROD and I can't see where the difference is...

The following code addition to the bottom of template.php should be (but isn't) adding the caption class to images such as the one at the top of this page:

https://www.transitionnetwork.org/blogs/ed-mitchell/2013-06/test-blog-test-caption-and-featured-image

Any reason you can think of why not? Or do you know of another easy way of adding the class caption to featured image fields? (I guess the module https://drupal.org/project/semantic_cck - but maybe overkill...)

/

  • Adds caption css class to featured images */

function transition2_imagecache_formatter_featured_image_default($element) {

Inside a view $element may contain NULL data. In that case, just return.
if (empty($element#itemfid?)) {

return ;

}

Extract the preset name from the formatter name.
$presetname = substr($element#formatter, 0, strrpos($element#formatter, '_'));
$style = 'linked';
$style = 'default';

$item = $element#item;
$itemdata?alt? = isset($itemdata?alt?) ? $itemdata?alt? : ;
$itemdata?title? = isset($itemdata?title?) ? $itemdata?title? : NULL;

$class = "imagecache imagecache-$presetname imagecache-$style imagecache-{$element#formatter} caption";
return theme('imagecache', $presetname, $itemfilepath?, $itemdata?alt?, $itemdata?title?, array('class' => $class));

}

Change History

comment:1 Changed 3 years ago by benj

  • Owner changed from laura to jim
  • Status changed from new to assigned

comment:2 Changed 3 years ago by jim

  • Cc ed, ben added

Adding Ed and Ben to CC list...

comment:3 follow-up: ↓ 5 Changed 3 years ago by jim

  • Cc benj added; ben removed

That's benj, not ben...

comment:4 Changed 3 years ago by laura

Hi Ben

I'll have a look through my old notes here tomorrow when back at the desk.  I remember we set up a captions effect for the individual ingredients, but would need to take a look back to see if I have notes on how these worked, could v poss have been a Jim thing he set up, then I styled up after when everything was in place on the ingredients.
Don't think (but could well be wrong!) we used one of the caption format modules that I tend to use on other Drupal sites.
Will have a look tomorrow eve, and get back to you if can find anything that may help.
Hope all is well, 
Best
Laura

On 16 Sep 2013, at 17:58, "Transiton Technology Trac" <trac@tech.transitionnetwork.org> wrote:

> #596: Captions issue
> ------------------------------------+-----------------------------------
>                 Reporter:  benj    |                Owner:  laura
>                     Type:  defect  |               Status:  new
>                 Priority:  minor   |            Milestone:  Maintenance
>                Component:  Theme   |             Keywords:
> Estimated Number of Hours:  0       |  Add Hours to Ticket:  0
>                Billable?:  1       |          Total Hours:  0
> ------------------------------------+-----------------------------------
> basically captions are appearing on body inline images and featured images
> on STG but not PROD and I can't see where the difference is...
> 
> The following code addition to the bottom of template.php should be (but
> isn't) adding the caption class to images such as the one at the top of
> this page:
> 
> 
> https://www.transitionnetwork.org/blogs/ed-mitchell/2013-06/test-blog-
> test-caption-and-featured-image
> 
> Any reason you can think of why not? Or do you know of another easy way of
> adding the class caption to featured image fields? (I guess the module
> https://drupal.org/project/semantic_cck - but maybe overkill...)
> 
> /**
>  * Adds caption css class to featured images
>  */
> function transition2_imagecache_formatter_featured_image_default($element)
> {
>   // Inside a view $element may contain NULL data. In that case, just
> return.
>   if (empty($element['#item']['fid'])) {
>     return '';
>   }
> 
>   // Extract the preset name from the formatter name.
>   $presetname = substr($element['#formatter'], 0,
> strrpos($element['#formatter'], '_'));
>   $style = 'linked';
>   $style = 'default';
> 
>   $item = $element['#item'];
>   $item['data']['alt'] = isset($item['data']['alt']) ?
> $item['data']['alt'] : '';
>   $item['data']['title'] = isset($item['data']['title']) ?
> $item['data']['title'] : NULL;
> 
>   $class = "imagecache imagecache-$presetname imagecache-$style
> imagecache-{$element['#formatter']} caption";
>   return theme('imagecache', $presetname, $item['filepath'],
> $item['data']['alt'], $item['data']['title'], array('class' => $class));
> }
> 
> -- 
> Ticket URL: <https://tech.transitionnetwork.org/trac/ticket/596>
> Transition Technology <https://tech.transitionnetwork.org/trac>
> Support and issues tracking for the Transition Network Web Project.

comment:5 in reply to: ↑ 3 Changed 2 years ago by chris

  • Cc ben added

Replying to jim:

That's benj, not ben...

Not any more!

Cc ben added, see ticket:738

Note: See TracTickets for help on using tickets.