Opened 15 years ago
Closed 3 years ago
#11725 closed feature request (wontfix)
Add start and count attributes to gallery shortcode
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 2.9.1 |
Component: | Gallery | Keywords: | has-patch |
Focuses: | Cc: |
Description
Add shotcodes COUNT for views full gallery after click on MORE. Home
Modify files ./wp-includes/media.php
Lines 699 (add COUNT => '-1')
Lines 767-798 (add ForEach ... )
Use in WP:
[gallery] ... show standard gallery
OR
[gallery count=3] ... show images 1-3
- more -
[gallery count=3+] ... show images 4-n
Attachments (7)
Change History (39)
#1
@
15 years ago
- Component changed from Media to Gallery
- Keywords needs-patch added; gallery photo images removed
#4
in reply to:
↑ 3
;
follow-up:
↓ 5
@
15 years ago
Replying to frymi:
SVN not work :-( ...
error: Commit failed, Server sent 403
You need to generate a patch and attach it here. If accepted for WordPress, a core developer (there are five of them) will then commit the patch. (403 is an unauthorized error code.)
#7
@
15 years ago
- Keywords needs-patch added; gallery post split gallery removed
I think count = -1 and the "+" are both hacks. Just a thought: If this is to make it in core, I think a patch should add two arguments: count, and start. Thus, you'd do [gallery count="3"] (start = 1 implied) and [gallery start="4"] (count = all implied) and [gallery count="2" start="5"] (the fifth and sixth images only).
Patch also broke some code conventions related to indenting (use tabs), use of comments (most of the ones you added aren't needed), and control structure whitespace (more at http://codex.wordpress.org/WordPress_Coding_Standards).
We also can't just strip out that CSS without accounting for it elsewhere. That should be handled in another ticket (and there probably is one already).
Back to needs-patch. Also, the keywords you added are useless to our workflow here. (Somewhat incomplete list at http://codex.wordpress.org/Reporting_Bugs#Trac_Keywords).
#8
@
15 years ago
nacin: Now updated files...
- change arguments (start, count)
- added comments
OK?
PS: I am czech and dont speak english ;-)
#10
@
15 years ago
- Summary changed from Views images (1-3 from gallery) in post, and other images show after click on MORE to Add start and count attributes to gallery shortcode
Don't worry about the extra attachments. Though we only are looking for patches, the full files aren't very useful.
I meant less comments, not more -- most code is self explanatory. The patch is still a mess, unfortunately. It isn't up to WordPress inclusion standards yet. You have issues with indentation and white space, the CSS needs to remain in there, etc.
#12
@
15 years ago
Lines 698-700 - commas should be after the array items, not before.
Comment on 760 isn't necessary (or should be intended and lowercased).
count() call on 762 should be lowercase.
and &&, not OR and AND. (Not just for consistency, either -- they work differently,as PHP places them at different spots in operator precedence.) |
The continue statement is fine for < $start, but if we've gone beyond $start + $count, we should break instead that way we don't keep running the loop when we don't need to.
Though I haven't tested it, the logic looks like it would work fine. I would probably sanitize $count early though, instead of making numerous casts and checks throughout. And $start isn't sanitized at all. We have a function absint() that could help.
#14
follow-up:
↓ 16
@
15 years ago
Thanks for providing a patch and some code. I pretty much feel that this is more of hack than a pretty implementation - but your intentions are perfectly valid. If we provide such arguments I would like to see a gallery lookup function that returns the actual gallery images so that it can be used in other places as well, e.g. for other listings, gallery plugins and the like. Maybe a filter function which runs on $attachments can do the job as well, so there is no need to interfere with the foreach iteration.
If not, this looks pretty much like a plugin to me that can filter the galleries output. To better support it we can add more hooks (I ran over the problem that galleries output can not be properly manipulated if you do not do any advanced workarounds).
#15
@
15 years ago
For example: this patch is used here http://www.predskolaci.cz/?cat=24
In open category > show images 1-3,1-6 [gallery count=3]
After click on post --more-- > show gallery, images 4-n [gallery start=4]
#16
in reply to:
↑ 14
@
15 years ago
- Keywords has-patch added; needs-patch removed
- Milestone changed from Unassigned to Future Release
I added another patch that cleans up the logic and sanitization a bit.
I'm not sold that this is core material but I do find it useful, being able to break up a gallery across pages, a more tag, or paragraphs of text, etc.
has-patch, adding to future release for now.
#17
@
15 years ago
- Keywords has-patch removed
nacin: 11725.diff - not work right.
[gallery count=6] not views 1-6 img, but show 7 img!
[gallery start=4] is OK
...
Line 776 must by: $start + $count -1
yes?
#21
@
15 years ago
Cross-referencing #7958. I like "limit" over "count" that originated there, I think.
#22
@
14 years ago
Maybe I'm missing what you guys are trying to accomplish here, but why doesn't the patch just pass start-1 as offset
and count as numberposts
to get_posts()
and get_children()
? I'm uploading a patch to show what I mean (although I didn't really test it).
#23
@
13 years ago
I personally like Aaron's solution as it is more flexible than a straight up limit clause. However, I would change the wording from count to limit as it makes more sense IMHO.
#30
@
10 years ago
Because it seems that this functionality will never make it into the Wordpress Core, I created a plugin that does something similar: https://wordpress.org/plugins/limit-parameter-for-gallery-shortcode/
It should be possible to integrate offset functionality pretty easy. I will happily accept a patch for this.
#32
@
3 years ago
- Resolution set to wontfix
- Status changed from new to closed
I'm going to close this one out.
There has been no interest shown in a decade, and I'm not really convinced this is a good addition to Core. It could get really confusing when using different orderby
options and combining with an offset
/start
value, and I don't really understand the use case. I'm guessing the idea would be to have pagination, or link off to a full gallery page? But both seem like a poor user experience that would require some custom templates in a theme.
Additionally, with the introduction of the block editor and full site editing, shortcodes (though still supported) are no longer the recommended way to display a gallery.
Please format this as a patch:
http://core.trac.wordpress.org/wiki#HowtoSubmitPatches