Support » Plugin: Photoswipe Masonry Gallery » Does your plugin serve srcset?

  • Hello, thank you for your good work.

    I’m a wp newbie trying to familiarize myself with what my plugins are doing.

    On this page:
    I noticed, a single image is being served multiple srcset images. Is it your plugin doing that?. If not, can you tell what plugin is doing that?
    <figure id="attachment_1843" style="width: 1000px" class="wp-caption aligncenter"><a class="single_photoswipe" href="" data-size="1000x667"><img class="size-full wp-image-1843" src="" alt="Jame Mosque Of Gonabad, Razavi Khorasan Province, Iran" width="1000" height="667" srcset=" 1000w, 288w, 768w, 494w, 600w" sizes="(max-width: 1000px) 100vw, 1000px" /></a><figcaption class="wp-caption-text">Jame Mosque of Gonabad, Razavi Khorasan Province, Iran</figcaption></figure>

    My second question:

    I disabled your plugin and the class=”single_photoswipe” is still there. But I don’t have any other plugins for photoswipe. So I’m trying to figure out why where class=”single_photoswipe” comes from. Any ideas?

    (I’m reactivating your plugin so when you visit my page, it will be active.)

    Thanks in advance.

    • This topic was modified 2 years, 8 months ago by Ali.T.. Reason: more explanation
Viewing 13 replies - 1 through 13 (of 13 total)
  • Hi, srcset is standard with WordPress now.

    single_photoswipe might be embedded in your theme. The plugin doesn’t make any permanent changes to your site.

    Hi is there anything we need to do to make srcset work with photoseipe?
    We load the images with acf gallery and on mobile it’s loading the full size images, the same as desktop.

    Are you using our plugin with acf gallery?

    Yes we are, as it’s easier for the client in the admin than WordPress gallery

    Hmm, can you explain how you got that working? Did you edit the plugin?

    Please note we didn’t make the gallery >

    yep, here you go

    	$image_ids = get_field('gallery_images', false, false);
    	$shortcode = '[gallery ids="' . implode(',', $image_ids) . '"]';
    	echo do_shortcode( $shortcode );

    This loads in the images from acf
    We also then set the thumbnail sizes in the photoswipe settings to 0 0 and added the following css

    .psgal figure {
    	width: 25%!important;
    	-webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
    	-moz-box-sizing: border-box;    /* Firefox, other Gecko */
    	box-sizing: border-box;         /* Opera/IE 8+ */
    	padding: 2px!important;
    .psgal figure img {
    	width: 100%!important;
    	height: auto!important;
    	padding: 0px!important;
    .psgal figure a {
    	width: 100%!important;
    	height: auto!important;

    This makes the images fully responsive, so we can set the width to 50% mobile and 33.33% ipad etc and change the columns loaded by masonry.

    Not sure if this is needed in all cases, I but I found I had to also add the image sizes to functions.php probably as I had set thumbnails to 0 0 to take control of sizes.

    	add_image_size( 'photoswipe_thumbnails', 400, 9999, false );
    	add_image_size( 'photoswipe_full', 1800, 9999, false );

    Of course, someone could also have cropped images so they have a consistent grid of images but in this case we are using Masonry so it makes sense to have auto height.

    • This reply was modified 2 years, 8 months ago by sguk. Reason: formatted code and added additional css tag
    • This reply was modified 2 years, 8 months ago by sguk. Reason: Added image sizes code and comment
    • This reply was modified 2 years, 8 months ago by sguk.

    ps noted that your plugin “uses” photoswipe and yes you’re right of course, to make photoswipe use conditional images/ srcset would require some modification to the photoswipe js or php files.

    Thanks for posting the code. We use ACF for all our sites in-house but I was just curious. This might be useful for others also.

    sguk, you said:

    Yes we are, as itโ€™s easier for the client in the admin than WordPress gallery

    Would you please explain why or how it’s easier for the client in the admin?

    WordPress Gallery has improved since I last looked at it, I only realised recently you can now reorder by editing the gallery etc.

    If the whole admin uses ACF I find it’s better as ACF isn’t a wysiwyg area, so you don’t need to explain to the client to click “add media” then create gallery etc.

    In ACF it’s already a gallery field and there’s also no possibility they will try to put text there or a static image.

    In a custom built theme with specific page areas coded in, ACF gallery ensures instantly the client knows how to use it, can reorder, etc and see cearly what that area is.

    Obviously whether it’s easier or not is open to opinion, but in our case it is. This doesn’t however suggest there is anything wrong with WordPress Gallery itself.

    The other thing is WordPress Gallery lets you set the columns, I’m not sure how this would interrupt coding when using ACF gallery to do other things like add images for a fading slider etc.
    So again, just depends on usage.
    Hope this helps ๐Ÿ™‚

    Hello, Thanks for your explanation. If ACF gallery isn’t in the wysiwyg area, then the gallery has to appear in the preset area – correct? On my site, I drop in multiple galleries in different parts of the text, depending on the particular post. That kind of flexibility (on the fly placement of galleries) is NOT possible with ACF Gallery, correct?

    Also is ACF Gallery attached to the post – or can you reuse the same gallery in other posts?

    This is where your usage can vary when you are not staying within a design layout.

    However, ACF has a flexible fields option where you can have pre-coded multiple choice content areas, such as gallery, text with header, 2 column text you, image area etc + you can drag and drop the order of these.

    ACF gallery is attached to a post, but any post content can be pulled into another post or page. You can also use the global option or you can probably code in shortcodes too.

    ps qnother one which can be dropped in as and when is nextgen gallery. It’s separate from the normal media library and you can create multiple galleries in a separate section of wordpress. Each gallery has a shortcode ID and allows you to place it anywhere in your site.
    You can then update the gallery from within the nextgen page.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Does your plugin serve srcset?’ is closed to new replies.