Support » Plugin: Eazyest Gallery » Adding a special html php string at the end of an image Caption/Description

  • Resolved tmp_advisors


    I have selected and liked Lazyest gallery because I was able to add at the end of the caption/description string my which is specific. That is :

    In Lazyest Gallery I modified “Lazyest-fields.php” strating line 252 :

    `function thumb_description( $description, $image ) {
    $desc_default = $image->description;
    $description ….`

    Here my add:

    $lien = sprintf('<span class="interessant"><a href="%s%s" ><img src="/wp-content/plugins/lazyest-gallery/images/email-button-icon.png" align="middle" hspace="8px" title="Click here to complete your request" alt="Click here to complete your request" />Interesting</a></span>', $link, $message );

    $description .= $lien;

    to add at the end of the description string , a dynamic value character string that will pass as parameter the current image name, so the admin of the site will know which image user clicked on (this triggers the sending of an email with that filename in the message core).

    You see here that at I append at the end of $description my own string which I prepared before (of course I had to test the selected language to adapt and it became quickly cumbersome.
    Since my client wanted support of lots of languages I realized that transposh is not supported.

    Your created Eazyest gallery and indeed it supports Transposh.

    My problem is that I am lost on where to add my string in Eazyest gallery files so it will show after the normal description of an image.

    Do you think I could use extra fields as well for that ?

    Many thanks for your help,


Viewing 14 replies - 1 through 14 (of 14 total)
  • You can modify the functions with filters.

    add_filter("post_gallery", "my_custom_ezg_thumbnails",10,2);
    function ezg_custom_thumbnails() {
      // Remove the thumbnails function
      remove_action('eazyest_gallery_thumbnails','ezg_thumbnails', 5); 
      // Add custom thumbnails function
      remove_action('eazyest_gallery_thumbnails','my_custom_ezg_thumbnails', 5);
    add_action('eazyest_gallery_before_folder_content','ezg_custom_thumbnails', 1);
    // modified ezg_thumbnails() function
    function my_custom_ezg_thumbnails( $post_id = 0, $page = 0 ) {

    I tried the extra fields, but for me didn’t worked properly..
    Also, you could see if you find something you want to modify in the template files. Copy the theme files from Eazyest Gallery plugin directory to your template directory and feel free to edit the code.

    The wordpress template page calculations are simple –
    The default custom-post-types are: post, page, menu …
    Eazyest Gallery plugin uses galleryfolder for that.
    If single-galleryfolder.php doen’t exist it takes the single.php.
    There is a nice picture about templating in the WordPress codex:

    Hi klihelp,

    Thanks for taking the time to help. I’ll try this week-end and let you kow.


    Hello klihelp,

    I am not that familiar with digging into functions and afraid to break something.

    In your last reply you mention


    I do have found reference to them but I have not found the file that contains the actual code.

    Can you tell me where is that code located in the ezg plugin files ?

    Thanks for your help,


    Maybe easier if you add a filter to the post_gallery.

    Find the post_gallery() code in /frontend/class-eazyest-frontend.php#L1044

    if ( get_post_type( ) == eazyest_gallery()->post_type ) :
     // modify gallery output only for Eazyest Gallery post types
     add_filter("post_gallery", "my_custom_ezg_thumbnails",10,2);
     /** Modified eazyest_frontend()->post_gallery() function
     * /frontend/class-eazyest-frontend.php#L1044
     * Make sure you comment out the apply_filters("post_gallery","",$attr)
     function my_custom_ezg_thumbnails( $output, $attr ){
      // Comment this out
      // Allow plugins/themes to override the default gallery template.
      // $output = apply_filters('post_gallery', '', $attr);
      // if ( $output != '' )
      //     return $output; 

    Hello klihelp,

    I have problems understanding what you mean, since I do not know how it really work. Perhaps you can give me a hint on the following function I have found in “class-eazyest-fontend.php” :

    `function content_single_galleryfolder( $content ) {
    ob_start(); // buffer to use actions that echo content

    <div class=”eazyest-gallery”>
    <?php do_action( ‘eazyest_gallery_before_folder_content’ ); // this action is used for breadcrumb trail and for thumbnail images ?>
    <?php echo $content; // this is the text content like a regular WordPress post ?>
    <?php do_action( ‘eazyest_gallery_after_folder_content’ ); // this action is used for extra fields and for subfolders ?>

    $content = ob_get_contents();
    return $content;

    As far as I understand, this ob_start() starts storing in buffer list of thumnails and captions to be displayed and then ob_get_contents() flushes it to the $content string, and it is returned. OK fine but I do not know where effectively this do_action(‘eazyest_gallery_before_folder_content’) function code is ? I Need to modify it a little, that’s it.

    In order to follow your last advice, I need to see where is that code to change it to my need.

    Hope this is clear for you. Thaks for your time helping me.

    The storyline takes you to the post_gallery filter:
    The thumbnails output is very simple: Eazyest Gallery adds ezg_thumbnails() to eazyest_gallery_thumbnails filter, which added to eazyest_gallery_before_folder_content action.
    Basically ezg_thumbnails() collects all information and pass it to the built-in [gallery] shortcode, which applies the post_gallery filter.
    So, feel free to use the post_gallery filter on the eazyest gallery pages. See the example code from my last comment.

    Hello Klihelp,

    Some news.
    I have finally found where the caption was displayed and for some misterious reason it was not taking the ezg code but using the wp-includes\media.php standard version.

    I discovered that if I activate the use of extra fields then the ezg code is used.

    I am not that good in understanding you advices using filters. So I’ll stick to updating directly media.php.



    Hi Klihelp,

    Now I have another issue with EZG 0.3. The extra fields are available under eacu image but it does not keep any data that I enter (for example I have created a “price” extra field and I can enter a value but after saving that field resets to enpty.

    Have you encountered that problem ?

    Many thanks


    Yes, the plugin uses the default [gallery] shortcode. If you use the extra fields you see that the plugin uses the post_gallery filter.
    Best not to modify core wordpress files or core plugin files, because your modifications will be lost if you update them; but also it’s easier to forget about those modifications if you don’t mark it somewhere …

    See this thread for saving extra fields:


    This link mention your workaround but actually where should I insert that

    // Set excerpt mode to default
    add_action( 'load-post.php', 'kli_wp_force_excerpt' );
    function kli_wp_force_excerpt() {
        $_REQUEST['mode'] = 'excerpt';

    code ?

    All the code above goes into the theme (or plugin) functions.php file.

    Best to separate the action/filter modifications for admin and frontend:

    if ( is_admin() ) {
      // functions for admin part
    } else {
      // functions for front end part


    I did add the code in the file :


    but it has no effect on keeping data in an extra field.

    I am using the twenty twelve template.

    Let mknow where I am wrong,

    Many thanks for your great help,


    Setting excerpt mode to default for the gallery admin page solved the extra field savings.
    Hope this will be fixed in the plugin.

    Hi Klihelp,

    Just to let you know that I have given up and uninstalled Easyest Gallery. I am not good enough to even understand properly your very precise and synthetic statements. Iam trying to find another solution.

    Many thanks anyway for taking the time,

    All the best,


Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Adding a special html php string at the end of an image Caption/Description’ is closed to new replies.