We're merging with GenerateBlocks! Learn more here.

Support Forum

Please login to receive premium support.

Support for the free plugin can be found here.

Forum Replies Created

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • in reply to: Add title to image lightbox #26221
    Vlidi
    Participant

    Hi Elvin, and thank you – this works great!

    So whoever may need it, the complete solution for using WPSP as Lightbox gallery WITH CAPTIONS:

    1. For the Gallery preview mode (e.g. thumbnails in Carousel):

    – Use this code (child theme / Code Snippets):

    add_action( 'wp_footer', function () { ?>
    <script>
    jQuery( document ).ready( function( $ ) {
        $.featherlightGallery.prototype.afterContent = function() {
            var caption = this.$currentTarget.find('img').attr('alt');
            this.$instance.find('.caption').remove();
            $('<div class="caption">').text(caption).appendTo(this.$instance.find('.featherlight-content'));
        };
    } );
    </script>
    <?php } );

    – Style with this CSS:

    .caption {
    	background-color: #ffffff;
    	color: #aaaaaa;
    	padding: 5px;
    	font-size: 20px;
    }

    2. For the Gallery view mode in Lightbox;

    – Use this code (child theme / Code Snippets):

    add_action('wpsp_inside_image_container',function(){
    
    $image_id = get_post_thumbnail_id( get_the_ID(), 'full' );
    $image_alt = get_post_meta($image_id, '_wp_attachment_image_alt', TRUE);
    
    $caption = '<div class="wpsp-img-caption">';
    $caption .= $image_alt;
    $caption .= '</div>';
    
    echo $caption;
    });

    – Style with this CSS:

    .wp-show-posts-image{
    position: relative;
    }
    .wp-show-posts-image .wpsp-img-caption{
    position: absolute;
    bottom: 2%;
    left: 50%;
    transform: translateX(-50%);
    }

    ***

    This works for WPSP 1.1.3 and WPSP Pro 1.0.

    Thank you once again for the fantastic support!

    in reply to: Add title to image lightbox #26086
    Vlidi
    Participant

    Hey Elvin,

    actually, it is the other way around – I am trying to have a Carousel gallery with images, which turns into a Lightbox when you click on it.

    I am very sorry if this is considered odd or unusual request.
    There are plugins that do just that and I wanted to see if WPSP can be accommodated to have the similar output as e.g. here:
    https://wordpress.org/plugins/continuous-image-carousel-with-lightbox

    …or here:
    https://shapedplugin.com/how-to-create-wordpress-image-carousel-with-lightbox

    And the excellent WPSP can do it – I am now trying to add image captions for both states (Carousel & Lightbox).

    The Lightbox part is solved in the thread above (when the Gallery is activated) – thank you!
    I wanted to see if it is possible to have the captions as well when in the Carousel (preview) mode.

    Unfortunately, the solution doesn’t work as I get the code printed as text instead of captions above the images. It is inserted via custom Hook to wpsp_inside_image_container.

    There was a syntax error reported on this line:

    $caption .= .$image_alt;

    The output looks like this:

    Screen Shot 2021-01-29 at 13.37.28.png

    But please we can stop here if you feel this falls outside the scope of support.
    The GPP / WPSP support fantastic, you guys are simply great, and the last thing I want to do is to misuse it in any way.

    Thank you for all the help!

    in reply to: Add title to image lightbox #26041
    Vlidi
    Participant

    [For some reason I could not delete this doubled post, only edit.]

    in reply to: Add title to image lightbox #26036
    Vlidi
    Participant

    Hey Elvin,

    well, it should look sort of like this:

    mdbootstrap.com/snippets/jquery/mdbootstrap/884716

    amp.dev/documentation/examples/multimedia-animations/image_galleries_with_amp-carousel

    …so alongside the captions visible once you launh Lightbox, I would like to have them also visible before, while in Carousel mode.

    Thanks for looking into this!

    in reply to: Add title to image lightbox #25976
    Vlidi
    Participant

    Thank you very much, works great 🙂

    My last question: any way to display the captions while in Carousel mode, before we enter Lightbox?

    WPSP is simply great, very enthusiastic about the block editor version.
    And thanks once again for the fantastic support!

    in reply to: Add title to image lightbox #25937
    Vlidi
    Participant

    I have adjusted the snippet a bit like so:

    add_action( 'wp_footer', function() {
        ?>
    	<script>
    		jQuery( document ).ready( function( $ ) {
        $.featherlightGallery.prototype.afterContent = function() {
            var caption = this.$currentTarget.find('img').attr('alt');
            this.$instance.find('.caption').remove();
            $('<div class="caption">').text(caption).appendTo(this.$instance.find('.featherlight-content'));
        };		
    	</script>
        <?php
    } )

    …but still the errors appear, and no captions.

    in reply to: Add title to image lightbox #25933
    Vlidi
    Participant

    Hi Elvin, thank you!

    Unfortunately, still no captions.

    (I made sure to have something entered in Alt, Description and Caption fields, just in case.)

    In addition, the console produces this error:

    Uncaught TypeError: Cannot read property 'prototype' of undefined

    …pointing to this line:

    jQuery.featherlightGallery.prototype.afterContent = function() {

    Maybe I messed something up, so here’s the full code I used:

    add_action( 'wp_footer', function() {
        ?>
    	<script>
    		jQuery( document ).ready( function( $ ) {
        $.featherlightGallery.prototype.afterContent = function() {
            var caption = this.$currentTarget.find('img').attr('alt');
            this.$instance.find('.caption').remove();
            $('<div class="caption">').text(caption).appendTo(this.$instance.find('.featherlight-content'));
        };
    } );
    	</script>
        <?php
    } );

    Any idea?

    Thanks!

    in reply to: Add title to image lightbox #25920
    Vlidi
    Participant

    Hey Tom, thank you!

    After a long while of juggling things around – and breaking Code Snippets 🙂 – I finally think I have it assembled properly.

    Unfortunately, still no captions.

    Can you confirm that the code is OK?

    Looks like this now:

    add_action( 'wp_footer', function() {
        ?>
    	<script>
    		jQuery.featherlightGallery.prototype.afterContent = function() {
    			var caption = this.$currentTarget.find('img').attr('alt');
    			this.$instance.find('.caption').remove();
    			jQuery('<div class="caption">').text(caption).appendTo(this.$instance.find('.featherlight-content'));
    		};
    	</script>
        <?php
    } );

    …and if the code is good, does it mean that there is no way to have captions at all?

    Thanks!

    in reply to: Add title to image lightbox #23730
    Vlidi
    Participant

    P.S.
    I am aware that you posted this fix, but I am doing something wrong, as however I replace $ instances, the Code Snippets complains.
    And this is where my PHP mastery ends :-/

    Thanks!

    in reply to: Add title to image lightbox #23726
    Vlidi
    Participant

    Hi Tom & WPSP team,

    was just browsing the Forum to try to find the solution for captions, and I learn that the block version is coming, yey!

    I would like to give the Featherlight code a chance in the meantime, and great that it promises to pull the content from the “alt” tab.

    But it gives the following error and Code Snippets kindly refuse to proceed:

    Fatal error on line 1:

    syntax error, unexpected '.', expecting variable (T_VARIABLE) or '{' or '$'

    I see the exact same code working on their demo.
    How should I adapt it for GP?

    Thanks!

    in reply to: Cards: How to keep images on the same side #11760
    Vlidi
    Participant

    Works great.
    Once again, fantastic support!
    Thanks!

    in reply to: Styling the “No results” message #11655
    Vlidi
    Participant

    Thanks Tom, all works as expected.
    Great plugin, great support!

    in reply to: Styling the “No results” message #11600
    Vlidi
    Participant

    Hi Tom, and thanks so much for the swift response. This selector works great, of course 🙂

    Re: my question No 2: is there a way to insert some (simple) HTML in the No Results message, like a link?

    Thank you!

Viewing 13 posts - 1 through 13 (of 13 total)