victorjonsson / Arlima

Article List Manager - Wordpress plugin suitable for online newspapers that's in need of a fully customizable front page
28 stars 16 forks source link

Image caption on images in list #45

Closed ErikXXon closed 10 years ago

ErikXXon commented 10 years ago

Have try to get the wordpress image caption to work with Arlima listed images. Have looked into filters and so on,.. is that hard to get?

I would have it to write some info like: Photo by: ....

Maby this code: // Caption (explicitly) echo $post->post_excerpt; // Raw if ( has_excerpt() ) { the_excerpt(); }

victorjonsson commented 10 years ago

I was surprised that the filter needed in this case didn't already exist... It's implemented now however. I've added the following to the documentation.


You can use filter arlima_article_image_tag if you only want to decorate the HTML of the generated image.

// Add caption to arlima images displayed in full
function my_arlima_image_captions($html, $img_size, $article) {
  if( $img_size == 'full' ) {
    $attach = get_post($article['image']['attachment']);
    $img_template = '<div class="img-wrapper">%s<div class="caption">%s</div></div>';
    $html = sprintf($img_template, $html, $attach->post_excerpt);
  }
  return $html; 
}
add_filter('arlima_article_image_tag', 'my_arlima_image_captions', 10, 3);