Okay
  Public Ticket #2383825
Caption in lightbox gallery
Closed

Comments

  • Robin started the conversation

    Hi There,

    I just purchased the Munio portfolio theme and I have already been speaking with the author to receive support for adding some caption when pictures displayed in the lightbox?[please refer to screenshot attached]

    The plugin used is the current: magnific-popup.
    I have read the link below in the documentation but I couldn't make much sense in what I would need to change in order to display the image caption/description in the lightbox gallery.
    https://dimsemenov.com/plugins/magnific-popup/documentation.html

    By inspecting the theme , there is an element in the lightbox called ‘mfp-bottom-bar’ where there is a ‘mfp-title’. Right now is set to display none, but I presume we could probably display it afterall with some css when hovering on with the mouse. Do you recon a mpf-caption would be easy to be added there and pull a caption content?[please refer to screenshot attached]

    I appreciate your help and support on the matter.
    Regards

  •  1,803
    Support replied

    Hi Robin,

    we can do a custom work for a certain fee if you are interested.

    Otherwise we can give you pointers on what & where to change.

    If first option is preferred, we can discuss the price and send us wp admin access with full rights using Appearance -> Editor

    Thank you.

    Clapat Support

    https://www.clapat.com/

    Review Envato Item Support Policy

  • Robin replied

    Hi there,

    Many thanks for your reply. 

    I am currently a developer even though just junior-mid level, but I would be happy to give it a try if some pointers and guidance are given. Unfortunately when speaking with the author of the theme I was not aware that there would be a fee for custom work, and due to the fact that this project is for a third party I couldn’t afford to purchase the custom work option. 

    Would it be possible to receive here via messages some guidance on the work to do for the captions?

    Many thanks again


    Robin

  •  1,803
    Support replied

    Yes, definitely.

    Our image popup shortcode is implemented in Munio Functionality Plugin that comes with the theme (in your installation you can find in /wp-content/plugins/munio-functionality-plugin and it can be edited using Plugins -> Editor)

    on line 626 in /include/shortcodes.php

    function shortcode_clapat_popup_image

    there you can see how the html of the image link is constructed

    $out .= '<a class="image-link ' . $atts['extra_class_name'] . '" href="' . $img_url . '">';
    $out .= '<img src="' . $thumb_url . '" alt="' . $alt_text . '" />';
    $out .= '</a>';

    one of the key elements is the class image-link

    so basically here is where you can change the html structure of the image pop up link required to suit your purpose.

    if you open /js/scripts.js (path relative to the parent theme) you will see that the image popup is initialized in function LightBox() line 2020

    Thank you.

    Clapat Support

    https://www.clapat.com/

    Review Envato Item Support Policy

  • Robin replied

    Many thanks for the reply.
    I will have a look at the code and see if I can achieve something with the pointers.
    Do you think you can do this in the main theme though? Would any change be overwritten in the future case of theme/plugin updates?

  •  1,803
    Support replied

    Hello Robin,

    I don't think we will modify the Munio Functionality Plugin however you need to merge your changes in /js/scripts.js in case you modify the LightBox() function.

    Thank you.

    Clapat Support

    https://www.clapat.com/

    Review Envato Item Support Policy

  • Robin replied

    Hi there, 

    Could I ask you the best way to merge my changes of the /js/scripts.js ? I have been trying(in my child theme) to enqueue a custom js and dequeue the parents one, but for some reason it is not working. 

    Many thanks
    Robin

  •  1,803
    Support replied

    Hello Robin,

    This is a good question. I am forwarding you this ticket (from one of our users) as reference:

    https://clapat.ticksy.com//ticket/2384788/

    Just replace 'bauman' with 'munio' and it should work.

    Important to note is that you use wp_dequeue_script and wp_deregister_script to dequeue the old script and you enqueue the child script version using get_stylesheet_directory_uri() to indicate the full path to the file.

    and keep the same name for the scripts handler.

    You also need to use wp_localize_script to pass the theme options

    Thank you.

    Clapat Support

    https://www.clapat.com/

    Review Envato Item Support Policy

  • Robin replied

    Oh so good this tickets that was opened! 

    I am not sure why I was trying to do the same but before it wouldn't work but now it is. I did not run the wp_localize_script but it all works fine with the js file so I believe it went through. 


    What I cannot still see is my title pulled through even though the js file now should be all correct.

    My aim is to dynamically display a caption in the following HTML part

    '<div class="mfp-figure">'+
                '<div class="mfp-close"></div>'+
                '<div class="mfp-img"></div>'+
                '<div class="mfp-bottom-bar">'+
                  '<div class="mfp-title">CAPTION HERE</div>'+
                  '<div class="mfp-counter"></div>'+
                '</div>'+
              '</div>


    I added this code into the js file

    image: { titleSrc: function(item) { return item.el.attr('info') + '<small>by Marsel Van Oosten</small>'; } },


    and to grab the caption on the info I amend the shortcodes.php to this 


    add_shortcode('clapat_collage_image', 'shortcode_clapat_collage_image');

    function shortcode_clapat_collage_image($atts, $content = null) {
    $atts = shortcode_atts(array( 'thumb_img_url' => '', 'thumb_img_id' => '', 'img_url' => '', 'img_id' => '', 'alt' => '', 'info' => '' ), $atts );
    $img_url = munio_get_image_url($atts['img_id'], $atts['img_url']); $thumb_img_url = munio_get_image_url($atts['thumb_img_id'], $atts['thumb_img_url']); $info = $image_info->post_excerpt; $str = '<div class="collage-thumb">'; $str .= '<a class="image-link" href="' . esc_url( $img_url ) . '">'; $str .= '<img src="' . esc_url( $thumb_img_url ) . '" alt="' . esc_attr( $atts['alt'] ) . '" />'; $str .= '<div class="thumb-info"><h6>' . wp_kses_post( $atts['info'] ) . '</h6></div>'; $str .= '</a>'; $str .= '</div>';
    return $str;

    }

    It all seem to be working fine but the function are not grabbing any caption. Is there any way I could get some help into this?

    Thank you,
    So grateful to have such a good support theme!
    Robin

  •  1,803
    Support replied

    Hi,

     what's the page url with the popup image?

    Thank you.

    Clapat Support

    https://www.clapat.com/

    Review Envato Item Support Policy

  •  1,803
    Support replied

    Hello,

    you have an 'undefined' value in the mfp-title

    https://prnt.sc/sey25z

    Thing is that you need to specify the info attribute which I don't see anywhere in your <img> or <a> tags (not sure actually which has to have the attribute but let's suppose it's the <img>)

    https://prnt.sc/seyb89

    So you have to go back to the shortcode implementation

    ...

    $str .= '<img src="' . esc_url( $thumb_img_url ) . '" alt="' . esc_attr( $atts['alt'] ) . '" info="' . esc_attr( $info ) . '" />'; 

    ...

    Thank you.

    Clapat Support

    https://www.clapat.com/

    Review Envato Item Support Policy

  • Robin replied

    Hi Clapat team, 

    That is where I was trying to make my changes already but I could not find a correct way to target the images caption. 
    I will try to have a look at the code again and see where needed to be amended.

    However if you have any further advice, I will be happy to hear.

    Thank you.
    Robin

  •  1,803
    Support replied

    It looks like the only thing left for you is to assign the info attribute to the image in shortcodes.php

    $str .= '<img src="' . esc_url( $thumb_img_url ) . '" alt="' . esc_attr( $atts['alt'] ) . '" info="' . esc_attr( $info ) . '" />'; 

    Thank you.

    Clapat Support

    https://www.clapat.com/

    Review Envato Item Support Policy