Skip to content
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 Block: Missing 'Random Order' setting #9701

Closed
vr-gallagher opened this issue Sep 7, 2018 · 13 comments · Fixed by #57477
Closed

Gallery Block: Missing 'Random Order' setting #9701

vr-gallagher opened this issue Sep 7, 2018 · 13 comments · Fixed by #57477
Assignees
Labels
Backwards Compatibility Issues or PRs that impact backwards compatability [Block] Gallery Affects the Gallery Block - used to display groups of images [Status] In Progress Tracking issues with work in progress [Type] Enhancement A suggestion for improvement.

Comments

@vr-gallagher
Copy link

vr-gallagher commented Sep 7, 2018

In the classic editor, when I go to set up a WordPress image gallery, there are "Gallery Settings" for "Link To", number of "Columns", "Random Order", "Size", and "Type" ("Thumbnail Grid", "Slideshow"). Those settings are missing in Gutenberg Version 3.7.0 when using the "Gallery" block.

Related: The captions on the Gutenberg "Gallery" block are styled so that the caption hangs oddly over the image. The images also can't be clicked on (possibly because there is no "Link To" option, as mentioned).

To Reproduce
Steps to reproduce the behavior:

  1. Use the 'Gallery' block
  2. Click on 'Media Library'
  3. Select Images
  4. Click on 'Create a new gallery'
  5. Now you are on the final gallery set-up page. Above the 'Insert Gallery' button is a blank area—in that blank area is where the settings I mentioned would normally appear in the classic editor.

Expected behavior
I expected the Gutenberg "Gallery" block to have "Gallery Settings" so that I'd have control over the following options: "Link To", number of "Columns", "Random Order", "Size", and "Type" ("Thumbnail Grid", "Slideshow").

Screenshots
screen shot 2018-09-07 at 1 15 37 pm
screen shot 2018-09-07 at 1 16 27 pm
screen shot 2018-09-07 at 1 17 34 pm

Desktop (please complete the following information):

  • OS: iOS
  • Browser: Firefox
  • Version: 61.0.2

Additional Context

  • I'm on the Genesis framework
@0aveRyan 0aveRyan added [Type] Bug An existing feature does not function as intended [Feature] Blocks Overall functionality of blocks [Feature] Media Anything that impacts the experience of managing media labels Sep 7, 2018
@0aveRyan
Copy link
Contributor

0aveRyan commented Sep 7, 2018

I've replicated this bug against master on a vanilla install. No console errors so bug will require some discovery.

@saulirajala
Copy link

Gallery settings were hidden in PR #1978, because Gutenberg didn't use them. I believe settings should now be made in post edit -screen after images are inserted to gallery:

nayttokuva 2018-09-30 kello 14 54 50

I wasn't able to replicate the front-end issue. I tested in desktop Chrome and Firefox with Gutenberg 3.9.0 (master branch) and twentyseventeen -theme. Could caption-gradient -issue be relating to Genesis framework?

@Soean Soean added the [Block] Gallery Affects the Gallery Block - used to display groups of images label Oct 26, 2018
@quicoto
Copy link

quicoto commented Jan 21, 2019

Aren't we missing the "order" settings? Like inverse order and such?

@cjyabraham
Copy link

Aren't we missing the "order" settings? Like inverse order and such?

Yes. It would be great to have back the orderby parameter like the gallery shortcode has. Any chance we could get this in?

@a4jp-com
Copy link

Please bring back the random order setting.

@noisysocks
Copy link
Member

Here's what is in gallery settings when using the classic editor:

Screen Shot 2020-04-21 at 17 03 44

And here's what is in gallery settings using the latest development version of the block editor:

Screen Shot 2020-04-21 at 17 03 53

The only missing setting is Random Order. It's difficult to implement this in the gallery block right now, though, as it is a static block that does not use the [gallery] shortcode.

We could look into making the gallery block dynamic. I'm not totally convinced, though, that supporting Random Order is worth the complexity and performance penalty that making this block dynamic would add.

One way around some of that complexity would be to wait until the gallery block uses inner blocks. The render_callback would then only have to shuffle an array instead of parse gallery HTML.

For now, the workaround here is to use the shortcode block to insert a [gallery] shortcode.

@noisysocks noisysocks added [Type] Enhancement A suggestion for improvement. Backwards Compatibility Issues or PRs that impact backwards compatability and removed [Feature] Blocks Overall functionality of blocks [Feature] Media Anything that impacts the experience of managing media [Type] Bug An existing feature does not function as intended labels Apr 21, 2020
@noisysocks noisysocks changed the title Gallery Block Missing Gallery Settings Gallery Block: Missing 'Random Order' setting Apr 21, 2020
@a4jp-com
Copy link

I'm happy using the classic mode till something can be figured out but it would be nice if this was in the block settings. Having random images in sites is cool. Especially design sites.

@echivalent
Copy link

after 2 years of developing versions, there is still missing that random option, or I am doing something wrong?

@a4jp-com
Copy link

a4jp-com commented Jul 1, 2022

It still hasn't been added but I hope it can be added one day. I have so many sites I'd like to add dynamic galleries to. We can do lots of different things with blocks now that can't easily be done in classic mode any more as well.

@cagrimmett
Copy link

@noisysocks

The only missing setting is Random Order. It's difficult to implement this in the gallery block right now, though, as it is a static block that does not use the [gallery] shortcode.

We could look into making the gallery block dynamic. I'm not totally convinced, though, that supporting Random Order is worth the complexity and performance penalty that making this block dynamic would add.

I don't think the Gallery in the Classic editor did not randomize the order of the images displayed in the gallery in the editor when the Random Order option was checked, only on the published post/page. In the same spirit, one option would be to add the Random Order option setting back to the block and add in a conditional to shuffle the innerBlocks array before the foreach outputs them on the front-end.

I think it is okay if the images are not in a random order in the editor if it avoids the complexity of making it a dynamic block. Perhaps changing the name of the option to "Randomize the order of the images in the published [posttype]" to make that clear would avoid user confusion.

@a4jp-com
Copy link

I need the random order for lots of sites I work on. It would be great if the gallery block could be made dynamic. The images only need to be randomized on the front end not in the editor as that makes work difficult.

@t-hamano
Copy link
Contributor

Whether we want to implement this functionality in Gutenberg or not, I think it can be achieved using render_block_data hooks. For example, the following will shuffle the order of images in the front end if the gallery block contains the class name "random".

function gutenberg_should_render_lightbox( $block ) {

	if ( 'core/gallery' !== $block['blockName'] ) {
		return $block;
	}

	if ( ! isset( $block['attrs']['className'] ) ) {
		return $block;
	}

	if ( false === strpos( $block['attrs']['className'], 'random' ) ) {
		return $block;
	}

	$inner_blocks = $block['innerBlocks'];
	shuffle( $inner_blocks );
	$block['innerBlocks'] = $inner_blocks;

	return $block;
}

add_filter( 'render_block_data', 'gutenberg_should_render_lightbox', 15, 1 );

The gallery shortcode also has options such as orderby, order, id, include, and exclude. However, in the case of the Gallery block, you can control what images are included and in what order they are displayed, so the only thing missing is the random option.

@a4jp-com
Copy link

Yes please.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backwards Compatibility Issues or PRs that impact backwards compatability [Block] Gallery Affects the Gallery Block - used to display groups of images [Status] In Progress Tracking issues with work in progress [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging a pull request may close this issue.