WordPress.org

Make WordPress Core

Opened 9 years ago

Closed 6 years ago

Last modified 6 years ago

#18143 closed enhancement (fixed)

Add size for Gallery Settings

Reported by: designsimply Owned by: nacin
Milestone: 4.1 Priority: normal
Severity: normal Version: 3.2.1
Component: Gallery Keywords: westi-likes has-patch
Focuses: Cc:

Description

Add a size option for gallery settings so it's easy to insert a single column gallery with large or full size images.

Attachments (6)

add-size-to-gallery-settings.diff (2.8 KB) - added by designsimply 9 years ago.
18143.1.diff (3.5 KB) - added by designsimply 9 years ago.
Adding column update on size change.
18143-add-gallery-settings-size-field.png (238.3 KB) - added by designsimply 9 years ago.
18143.2.diff (3.7 KB) - added by designsimply 9 years ago.
Change 'Size' to 'Image size'
18143.3.diff (4.8 KB) - added by richardmtl 6 years ago.
18143.4.patch (1.1 KB) - added by noplanman 6 years ago.

Download all attachments as: .zip

Change History (33)

#1 @westi
9 years ago

  • Keywords 3.3-early westi-likes added
  • Milestone changed from Awaiting Review to Future Release
  • Owner set to westi
  • Status changed from new to accepted
  • Version set to 3.2.1

#2 @nacin
9 years ago

  • Milestone changed from Future Release to 3.3
  • Owner changed from westi to nacin

#3 @nacin
9 years ago

I thought there was a filter on Thumbnail/Medium/Large/Full in image_size_input_fields() that we could apply here, but there isn't.

#4 @nacin
9 years ago

  • Keywords ux-feedback added

Patch works, tested, looks good. +1

However, when choosing "Large" or "Full", I want to think that number of columns should be reduced from 3 to 1, and that "Medium" should reduce columns to 2. That also makes me think that Size should appear immediately above the Columns section, and thus below the order fields.

Anyone disagree? What I did was add two images as [gallery size="large"] but the theme applied certain CSS due to the three columns (which I didn't notice) and at first I couldn't figure it out. (I don't ever really use galleries, so treat me as a user here.)

#5 @ryan
9 years ago

  • Milestone changed from 3.3 to Future Release

Punting enhancements from 3.3

@designsimply
9 years ago

Adding column update on size change.

@designsimply
9 years ago

Change 'Size' to 'Image size'

#6 @jane
9 years ago

  • Keywords 3.3-early ux-feedback removed
  • Milestone changed from Future Release to 3.4

Fine by me.

#7 @husobj
9 years ago

  • Cc ben@… added

#8 @ryan
8 years ago

  • Milestone changed from 3.4 to Future Release

#9 follow-up: @helgatheviking
6 years ago

Bumping this out of the dark ages. To change the size you have to go into the text editor and add a shortcode parameter. Easy, if annoying, for someone familiar with WP. Unlikely for someone who isn't. The rest of the gallery UI is pretty sweet, the lack of an image size parameter seems like an oversight.

#10 in reply to: ↑ 9 @richardmtl
6 years ago

@helgatheviking: It's really funny that you bumped this ticket, because I actually have plans to to give it a go this week, to see if I can update the patch from @designsimply, so keep your eyes peeled for it! :)

#11 follow-up: @helgatheviking
6 years ago

Glad to hear it! The shortcode parameter is already there and working, so you need to add the form and send the parameter to the editor. If someone can point me to a tutorial on how to test patches via git (i'm longing for WP to move to Git or at least become truly version control agnostic) I'd be happy to test what you come up with.

#12 in reply to: ↑ 11 @helen
6 years ago

Replying to helgatheviking:

If someone can point me to a tutorial on how to test patches via git (i'm longing for WP to move to Git or at least become truly version control agnostic) I'd be happy to test what you come up with.

The patch command is Unix, not VCS-dependent. We're pretty VCS-agnostic unless you're a committer, but even then, some committers use Git for everything but the commit itself.

@richardmtl
6 years ago

#13 @richardmtl
6 years ago

Sorry it took so long to get this updated, but here is my patch, finally. I took @sheri's diff and added my own modifications to it. The thing is, I'm not sure if all of the changes are actually necessary, especially the ones in media.php. I banged my head against that for a while before I stumbled upon media-template.php.

#14 @Stagger Lee
6 years ago

Thank you.
Seems as it is working OK. Probably wont be difficult to put custom image sizes.

I like that Jetpack carousel remove next/prew arrows when it is only one image.

And believe it is not 3.9.1 files, some lines numbers dont match. And also it is not easy to see when to add new lines, when to overwrite old lines.

Have to ask will it come into core or will we have to change files every time we upgrade WP ?

Last edited 6 years ago by Stagger Lee (previous) (diff)

#15 @richardmtl
6 years ago

@tagger Lee: Thanks for your comments. I actually want to revisit my patch over the next few days, I have a sneaking suspicion I missed something and so I have a couple of things I want to check.

Have to ask will it come into core or will we have to change files every time we upgrade WP ?


This will hopefully be merged into Core if the patch gets accepted.

#16 @Stagger Lee
6 years ago

Please give us few lines of code for functions.php. If it is not so much work to implement.
To have own image sizes.
Only reason for this would be to not change everything again when WP updates.

#17 @Stagger Lee
6 years ago

Did patch gets accepted for core ?

#18 @SergeyBiryukov
6 years ago

#27515 was marked as a duplicate.

#19 @SergeyBiryukov
6 years ago

#29590 was marked as a duplicate.

#20 @noplanman
6 years ago

I somehow didn't find this ticket, sorry.
Here's my patch for this in the current trunk (4.0-).

It still needs testing to make sure that it doesn't effect any other parts of WP.

@noplanman
6 years ago

#21 @SergeyBiryukov
6 years ago

  • Milestone changed from Future Release to 4.1

#22 @SergeyBiryukov
6 years ago

#29674 was marked as a duplicate.

#23 @wonderboymusic
6 years ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 29779:

Add size to the UI for Gallery Settings in the media modal. Ensure that the TinyMCE view is refreshed when size changes.

Props richardmtl, noplanman, wonderboymusic.
Fixes #18143.

#24 @Stagger Lee
6 years ago

For all those who cannot wait here is nice snippet for functions.php:
Some workaround, but not as GUI option.

function gallery_shortcode_change_default_size( $out, $pairs, $atts ) {
	
	if ('1' == $atts['columns']) {
		$out['size'] = 'gallery-thumbnail-l';
	} elseif ('2' == $atts['columns']) {
		$out['size'] = 'gallery-thumbnail-2';
	} elseif ('3' == $atts['columns']) {
		$out['size'] = 'gallery-thumbnail-3';
	} elseif ('' == $atts['columns']) {
		$out['size'] = 'gallery-thumbnail-3';
	}
	
	return $out;
}
add_filter( 'shortcode_atts_gallery', 'gallery_shortcode_change_default_size', 10, 3 );
Last edited 6 years ago by Stagger Lee (previous) (diff)

#25 @wonderboymusic
6 years ago

#29032 was marked as a duplicate.

#26 @Stagger Lee
6 years ago

I just noticed this solution makes a lot of problems with different scenarios.
How would now theme developers make SVG icons marking on blog list if a post has gallery. One image (one columns) is not precise a gallery, all posts with one image will be marked as post with galleries. I already have this problem on one website i testing this on.

And several other scenarios as well too.
Not good at all, not good.

Could you just make Jetpack carousel work even with simple and single images in post/pages/widgets ? What is so big deal, all lightbox plugins are already doing this.

Seems as less headache.

PS: Dont know what this option at the bottom "Reopen" is and if i may use it.

#27 @Stagger Lee
6 years ago

Just to write this snippet. For people who customize Blog lists in themes.
This is in the core now and putting "one-image" gallery and showing icon on Blog list that Post has gallery would be cheating in some way. One image is not gallery. This snippet takes care of it, goes in template loop:
(I used and activated Font Awesome SVG icons)

$attachments = get_children(
    array(
        'post_type' => 'attachment',
        'post_mime_type' => 'image',
        'post_parent' => $post->ID
    ));
if(count($attachments) > 2) {
    // <!-- Do something like show a slider -->
    $video_ids = '<i class="fa fa-picture-o"></i>';
} else {
    // <!-- Display a single image -->
}
Note: See TracTickets for help on using tickets.