-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gallery Image sizes - original image size isn't available #13851
Comments
Same here. See https://wordpress-demo.arnowelzel.de/lightbox-with-photoswipe/ - one gallery is a "Classic" block which links to the real images and below is a Gutenberg gallery which links to reduced size images. This makes no sense at all. |
I have this problem too. I made some tests. Tested on clear theme with all plugins disabled. |
Just adding: I'm struggling with this too. |
Experiencing the same issue here. It would be brilliant if the |
Any progress in this issue? There are already people asking for workarounds in my Lightbox plugin: https://wordpress.org/support/topic/gutenberg-gallery-links-to-large-image-instead-of-full-size/ |
Until this issue is addressed in the gutenberg-code, I made a quick & dirty workaround with JavaScript that works fine for me: It modifies the href attributes for the links and sets the data-widht and data-height attributes to "0". It has to be placed in the footer or at least after the gutenberg gallery html markup:
Have fun! |
Another user asking me why his gallery does not show full size images in my plugin which can be zoomed and again I explain that this is not my fault, but an issue of the Gutenberg gallery block: https://wordpress.org/support/topic/pic-size-smaller-and-no-zoom-using-gallery-vs-single-pic/ Would you please be so kind to check this issue and at least tell us, when a fix can be expected? Thank you! |
This bug is the only reason why I can't switch to the new Gutenberg editor. Please fix this. Thank you. |
Hello, any news on this? I think it would help much more developers if image sizes are included in image tags and full size image url used in image link. Please let us know, if it's planned to fix this issue. Thanks, Ivan. |
I tried tomzwick's solution, but it quickly ran into problems depending on the filename, so I wrote this much more bulletproof javascript and regex workaround that works in every situation unless you have numbersxnumbers(dot) multiple times in your filename (and I very seriously doubt this will happen).
Just place this script at the bottom of your template or page. |
How has no one been assigned this yet!? EDIT: There's a pull request waiting on someone to merge #16011 |
@Choccyhobnob It's just about 5 months... why the rush? Sorry, couldn't resist. :-( |
Hello, I found that setting the gallery pointing to the attachment page (instead of media file) allow to link full size image. It can temporarily solve the problem. But do we now when this strange behavior will be fixed? |
Yes that works but now we have to edit all the meta for each image, make sure we use a theme that displays attachments properly, give the users another couple of clicks etc. |
Still waiting for an update about it. |
edit: Thanks @blogjunkie! I somehow missed that! When I've uploaded images whose width is below the big_image_threshold (by default, it's 2560px), the gallery does link to the original image; I am unable to reproduce this bug. using Gutenberg 7.5.0 and the TwentyTwenty (1.1) theme (and WordPress 5.3.2) |
@skorasaurus thats not related to Gutenberg. Your images are getting scaled by WordPress itself. See: https://make.wordpress.org/core/2019/10/09/introducing-handling-of-big-images-in-wordpress-5-3/ |
This is now resolved, at least on my site anyway. It's not retroactive, you will need to remove your old galleries and re-add them back in but once done the 'media file' option links to the full size image not the 'large' image |
#16011 fixed this. |
I am on WP 5.4.1. This is NOT Fixed. |
Maybe we have/had two similar issues. Look at https://atari8bit.net/homebrew-cart-labels/ for an example (The repros gallery hasn't be remade, the other ones have. You can see it linking to the 1024x768 size on the old gallery but the full size image on the rest). What issue are you still seeing? |
I set link => media file. So if I want to have the medium image size with link to full original size, then I got full size image with link to fullsize image. I can't separately set gallery image size and preview size. |
See this example - Gutenberg gallery with "medium" size images and linked to the media files: https://wordpress-demo.arnowelzel.de/lightbox-with-photoswipe/ I don't see any issues here any longer. However - existing galleries have to be updated or delete/created again, otherwise the fix does not apply. |
It's needed that "upgrade" would be automatic. Moreover, I noticed that:
|
if you lazy like me, and have 100s of posts with same gallery that is missing dimensions heres fast regex to do that delete/create in one hook (be carefull - this will run always - stop it!) add_action( 'template_redirect', function (){
$w = new WP_Query( array(
'post_type' => 'portfolio' ,
));
while ( $w->have_posts() ) { // custom Q - never on main loop
$w->the_post(); $post_id = get_the_ID();
$con = get_post_field('post_content', $post_id) ;
// INPLACE GALLERY with same gallery with dimenszins (dont do manully 100s of posts man)
$con = preg_replace_callback( '/<!-- wp:gallery {"ids":\[(.*)\].*wp:gallery -->/', function ( $match ){
$h = '<!-- wp:gallery {"ids":[' . $match[1] . '],"columns":1,"sizeSlug":"full","className":"slider"} --><figure class="wp-block-gallery columns-1 is-cropped slider"><ul class="blocks-gallery-grid">' ;
$arr = explode(',', $match[1] );
foreach ($arr as $val ) {
$h .= '<li class="blocks-gallery-item"><figure><img src="' . wp_get_attachment_url( $val ) . '" alt="" /></figure></li>' ;
}
$h .= '</ul></figure><!-- /wp:gallery -->' ;
return $h;
}, $con );
// gallery replace with gallery+ (with sizes)
$post = array(
'ID' => $post_id,
'post_content' => $con
);
wp_update_post( $post );
}
} ); |
issue is with older galleries, created before early 2020 (ref #13851 (comment)) |
Yeah, this issue came up in today's Editor Bug Scrub meeting. After testing, we were unable to replicate in the current version of Gutenberg. Therefore, I am going to close this issue. |
Hello, I'd have the question related to images shown by gallery or image block.
In gallery are loaded responsive images with srcset attribute, what is pretty good but the link of image point to the downsized image link.
Example: I have an image my-image.jpg with size about 2560x1440px in gallery.
This is the html output:
Gallery
<img>
tag loads downsized image in size 1024x576pxmy-image-1024x576.jpg
, that's good. But<a>
tag points to the same downsized image so I can never access the original image. It's the problem for example when some fancybox/lightbox javascript plugin is used for gallery images, user isn't able to open image in original size to see details, he can access only downsized image.Is there any solution, or recommendation how could we use original image size in the link of image?
As an addition to this message, some good fancybox plugins, for example Photoswipe require to have defined image sizes in javacsript. Are there any hooks where we could access images from Gallery or Image block before they are rendered and add them some additional attributes with information about image? - it basically follows on my closed issue #13661
Thanks, Ivan.
The text was updated successfully, but these errors were encountered: