Skip to main content

Questions tagged [gallery]

Build in WordPress gallery. Used to show multiple pictures in a grid.

Filter by
Sorted by
Tagged with
33 votes
6 answers
16k views

Turn a URL into an Attachment / Post ID

Is there any way I can take a URL of an image and find the attachment or post id of that image in the database? Here is the situation: I'm in a loop going over all the 'img' tags that are surrounded ...
Ankur's user avatar
  • 433
24 votes
5 answers
76k views

How do I delete all UNUSED images from my uploads directory?

I am trying to clean out my uploads folders as they are now starting to take up too much room on my server. I have tried to use plugins to achieve this end such as DNUI and Cleanup Images but these ...
G-Olly's user avatar
  • 351
23 votes
3 answers
15k views

Split Content and Gallery

Is there a way to split up the post content and the gallery short code. I want to display the gallery outside my normal content no matter how or where it is placed. I can use this to get the shortcode ...
Howdy_McGee's user avatar
  • 20.7k
17 votes
2 answers
44k views

How to customise the output of the WP image gallery shortcode from a plugin?

We're building a plugin that displays posts, and we also want to display the image gallery when it is used in a post. However, we need to limit the number of photos displayed? Is that possible?
jnthnclrk's user avatar
  • 1,825
17 votes
4 answers
30k views

How to manually fix the WordPress gallery code using PHP in functions.php?

It's been talked many times that Wordpress outputs some really bad code for the built-in gallery function. This is the core code responsible for the gallery output (in /wp-includes/media.php): ...
its_me's user avatar
  • 4,502
17 votes
2 answers
16k views

How to extend the gallery block in Gutenberg?

I'm playing with Gutenberg ahead of its inclusion in core, and I'd like to know how to extend the existing gallery block to change its display. For example, instead of a grid of thumbnails I'd like to ...
leemon's user avatar
  • 1,938
14 votes
1 answer
5k views

Add custom fields to wp native gallery settings

i already searched for solution and found a lot of unsolved or obsolete topics. Custom wordpress gallery option | Custom field for default gallery However, I´d like to add some custom fields (...
rownn's user avatar
  • 141
13 votes
2 answers
7k views

ZIP up all images displayed in a [gallery] and offer as download link

I would like to offer my visitors the option to download the entire photo gallery (displayed on dedicated [gallery] pages) as a ZIP file displayed at the bottom of each gallery page. - The full-sized ...
Paul Thomson's user avatar
13 votes
1 answer
921 views

Modified wp.media.view.Settings.Gallery in Backbone JS, but editing doesn't work

I've added to the normal WordPress gallery popup (when clicking "Add Media" in the WordPress editor), in order to allow my custom gallery type to be selected (which interacts with / uses the main ...
Lloyd Jones's user avatar
11 votes
1 answer
2k views

Prevent WordPress from adding image' title automatically

I wrote a plugin that set default title for all non-set (empty) titles and leaves the titles set manually (non-empty). The problem is when I upload new photos (to gallery), WordPress by default set ...
PolGraphic's user avatar
9 votes
1 answer
1k views

Any way to add custom options to Gallery Settings?

Now that Wordpress has updated to version 3.5, the media gallery has been overhauled and this custom options solution doesn't appear to work anymore. I'd like to add a couple of fields to the gallery, ...
Thomas Azar's user avatar
8 votes
6 answers
11k views

Overide Gallery Default Link to Settings

Is there way to control the gallery default “Link to” setting? Using the image_default_link_type filter within a functions.php file works on inserting single images into posts but it doesn't seem to ...
Brian Wayne's user avatar
8 votes
9 answers
2k views

Creating a photo gallery in WordPress [closed]

At times I've tried a few different solutions for a WordPress-powered photo gallery. There are lots of options, including plugins and custom post types. Theme matters a lot, here. ma.tt has a pretty ...
8 votes
2 answers
5k views

get_post_gallery with Gutenberg

I have a site where I created a page that takes the gallery images from a post and puts them into a slider. I used the following code: // gets the gallery info $gallery = get_post_gallery( $post-&...
kosher's user avatar
  • 260
8 votes
4 answers
6k views

How can I alter the [gallery] markup?

I would like to change the markup created by [gallery] from what is it as standard (dl) to a unordered-list with a difference. Below is the desired markup: <ul> <li><a href="/path/...
PaulAdamDavis's user avatar
7 votes
2 answers
6k views

Validation error: Extending Gutenberg gallery block

I am trying to extend the Gutenberg core/gallery block to add some new functionality to my image gallery on the frontend. I have created a separate plugin to handle this task. I have registered my ...
Andreas's user avatar
  • 331
7 votes
1 answer
7k views

How to specify a class added to my gallery

I would like to add a class to my gallery short code, this is how I have added my class: [gallery class="small" columns="2" ids="350,349,302,305"]. Now the confusion comes in, I am not sure how to ...
Charne's user avatar
  • 71
7 votes
2 answers
2k views

Is it possible to query all posts that don't have an attachment?

I want to get a list of all posts that don't have an attachment and delete them. This question takes about getting all posts that have an attachment, but I want the reverse of it. The brute force ...
Sudar's user avatar
  • 809
7 votes
1 answer
2k views

Custom wordpress gallery option

I would like to add custom option to default wordpress gallery tab. I need something simple just a drop down to add offered style, this would add predefined class to gallery on client side and on ...
antanas_sepikas's user avatar
7 votes
1 answer
1k views

Make a really simple gallery structure

The default gallery structure of WordPress is really tortuous: <div id="gallery-1" class="gallery..."> <dl class="gallery-item"> <dt class="gallery-icon"> &...
1213's user avatar
  • 173
7 votes
1 answer
923 views

Best approach when modifying the Media Manager

I am trying to edit the Media Manager to allow the selection of a new option in the "Link to" select field. This Backbone template is currently defined in media-template.php <label class="...
Stewarty's user avatar
  • 322
7 votes
1 answer
1k views

How to have different captions for same image, for galleries?

Seems like I can't have the same image in different galleries with different captions. Is it possible to make that working in any way? Like if we could change the shortcut code that Wordpress is ...
Peter Westerlund's user avatar
7 votes
5 answers
3k views

Use a separate custom table (not posts) to handle file upload data

The Problem: Website that has over 100 photos per post. Could possibly swell posts-table beyond 100K entries within a few years. The Dilemma: Would much rather stick to default WP UI for handling ...
user28216's user avatar
6 votes
3 answers
9k views

Check if post/page has gallery?

I'd like to run some code only if a gallery (inserted with the [gallery] shortcode) has been inserted into a post/page. I did the following: gallery_shortcode($post->ID) ? $gallery = 1 : $gallery =...
csm232s's user avatar
  • 159
6 votes
2 answers
11k views

get_post_gallery_images returns thumbs . I want full size

I have the following code on my site. <?php // image gallery content if( has_shortcode( $post->post_content, 'gallery' ) ) { $gallery = get_post_gallery_images( $post-&...
chifliiiii's user avatar
  • 2,852
6 votes
1 answer
12k views

How to paginate wordpress [gallery] shortcode?

I am using wordpress gallery shortcode [gallery] I was wondering if there is anyway to paginate them without using a plugin.
Ruriko's user avatar
  • 543
6 votes
1 answer
922 views

Gallery Inside One Post

For image galleries, I need a code that uses next/previous links to bring you to the next/previous image in that post and keeps the images in the correct order you chose while inserting them into the ...
AndrettiMilas's user avatar
6 votes
0 answers
246 views

Customize WordPress Media Manager - Media Window

Im trying to customize the wordpress media manager "add media" window to get it as simple as possible to use. So i want to disable/ hide the following fields/ functions because i dont need some or ...
public9nf's user avatar
  • 386
5 votes
4 answers
26k views

How do i add class="fancybox" to the default gallery?

i tried this shortcode: [gallery class="fancybox" link="file" columns="5"] But the class="fancybox" isn't been added to the a href tag of each image. How can i add class="fancybox" to each a href ...
alex's user avatar
  • 1,112
5 votes
4 answers
19k views

How to get Page/Post Gallery attachment images in order they are set in backend using WP_Query()?

I am trying to retrieve all the images from the Gallery of a page in the order they are set in the backend. So far I have: $my_wp_query = new WP_Query(); $all_wp_pages = $my_wp_query->query( ...
Larry B's user avatar
  • 985
5 votes
3 answers
25k views

How to show description under an inserted image?

I'm using wordpress' native media manager. I have a problem. I can show the title under the image. But I want also to show the description. Is it possible to do?
SNaRe's user avatar
  • 173
5 votes
3 answers
6k views

Adding jquery and thickbox to WordPress theme

I would like to add thickbox for the template which I develop to WordPress. At this time I'm trying with a clean template that have only header.php, footer.php,index.php, and functions.php. I've ...
Danny Style's user avatar
5 votes
2 answers
8k views

add_filter and changing output captions of image gallery

I'd like to change only one output of native WP Gallery (in media.php) On Smashing Magazine (link) author advises to change whole gallery_shortcode function. But I wondered if is possible to change ...
cachaito's user avatar
  • 165
5 votes
4 answers
3k views

WP 3.5 and Galleries - how to count images?

I'm trying to figure out how to count and display the number of images in a gallery with WP 3.5. I was following an old post on Ottopress, querying the DB for attachments but it seems the galleries ...
javy's user avatar
  • 456
5 votes
2 answers
2k views

Navigate with keyboard in Gallery shortcode

I am using Wordpress Gallery shortcode and I was wondering if there is a way to navigate using the arrow keys? Like if I view an single image and used the right arrow to navigate to the next image in ...
Ruriko's user avatar
  • 543
5 votes
1 answer
1k views

Add existing images from Media Library in to custom gallery

I have [gallery] inside the post, and I'm interested in a way to add already existing images from media library in to this gallery? once I trying add any image I have only one option - insert into ...
tokmak's user avatar
  • 186
5 votes
1 answer
437 views

How to draw media details for Isotope gallery using Photoswipe

I am currently in the process of making a Wordpress gallery that draws directly from the Media Library and incorporates Isotope and Photoswipe. Using a modified version of this, I have successfully ...
Bluestocking's user avatar
5 votes
1 answer
3k views

Modifying the media-template.php file, the right way?

The [gallery] shortcode accepts the columns='0' as an attribute so that it doesn't insert any breaks in the HTML between gallery items, however this option is not available in Gallery Settings ...
Michael Ruta's user avatar
5 votes
2 answers
4k views

Cropped featured image replaces original image in gallery

Firstly, I have done my research as thoroughly as I possibly can. Searches have been made, but I have not found any advice or solution as to my exact issue. Ok, time to explain. Currently I am ...
Gilipe's user avatar
  • 149
5 votes
0 answers
818 views

Is there a core Sortable component in Gutenberg?

I managed to somewhat replicate the product gallery metabox from WooCommerce in Gutenberg using the third-party react-sortable-hoc component. As it seems that this component is no longer supported, I'...
leemon's user avatar
  • 1,938
4 votes
1 answer
5k views

How to call WP3.5 Media Library manager?

In the past Media Library window could be called like this: tb_show("Upload image", "media-upload.php?type=image&TB_iframe=1&width=640&height=520"); This still works in WP3.5. But I'm ...
Atadj's user avatar
  • 2,162
4 votes
4 answers
12k views

Load entire NextGEN gallery from single thumbnail?

I'm using Alex Rabe's NextGEN Gallery in a lot of client sites as a centralized image repository, and am finding I often need to load an entire gallery into a lightbox (invoked via a single thumbnail),...
aendra's user avatar
  • 1,045
4 votes
2 answers
1k views

Using variable from one filter in another filter

I have a filter for the Gallery Shortcode where I grab IDs for images used in a post and using the IDs I grab their meta data. Now I need a way to use the $copyright variable in a filter for grabbing ...
Ivan Topić's user avatar
4 votes
3 answers
401 views

Responsive Images

Is there a native function to display the correct responsive image size for post thumbnails or gallery images depending on the screen resolution? Normally I'm using: 1.Custom image sizes: function ...
p2or's user avatar
  • 227
4 votes
2 answers
23k views

How I can get image description/title/alt for gallery image?

I'm displaying a gallery image but I also want display the caption for image. I can get the info that we insert when us upload a image in WordPress Dashboard like "Title/Caption/ALT/Description". I ...
Zkk's user avatar
  • 175
4 votes
2 answers
2k views

how to have the gallery shortcode output one single UL list instead of several DL?

I need the built-in gallery shortcode to output UL instead of DL. How can I do it? I know I can use the 'post_gallery' filter, but that means almost duplicating the media's gallery_shortcode function. ...
Luca Reghellin's user avatar
4 votes
1 answer
2k views

First three images in post excerpt

I have certain posts that are nothing but [gallery] with quite a few images in them. Is there a way to define an auto generated excerpt to only display the first three images for these posts on the ...
sosukeinu's user avatar
  • 191
4 votes
1 answer
1k views

get images from post and make a zip

here is what i have so far. function zip_gallery() { global $post; $images = get_children(array('post_parent' => get_the_ID(), 'post_type' => 'attachment', 'numberposts' => -1, '...
chrismccoy's user avatar
4 votes
2 answers
776 views

Default WP Gallery - show only galleries of a certain category

I am using WordPress's default Gallery and adding categories to them. I now created a shortcode with a loop to get the Galleries to a page: if(! function_exists('test_shortcode')){ function ...
Serge Inácio's user avatar
4 votes
2 answers
21k views

How to get the first image gallery of a product in woocommerce in a loop

I want to display a product with a product image and when visitor hovers over that image, it will change to the first image from the product gallery. I am using this code to display the image gallery, ...
Mailmulah's user avatar

1
2 3 4 5
16