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
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
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
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
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
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
-1 votes
2 answers
8k views

How can I make all gallery images to open in a new window?

How can I make all gallery images to open the high resolution image in a new window?
Mario's user avatar
  • 139
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
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
2 votes
3 answers
4k views

WordPress gallery 'post_gallery' filter doesn't work with feeds?

We can use the post_gallery filter to modify/replace the default WordPress gallery template (AKA output code) to suit our needs. But this doesn't seem to affect the markup in RSS feeds. No matter ...
its_me's user avatar
  • 4,502
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
3 votes
1 answer
597 views

How do i link gallery thumbnails to different url's using the wp native gallery?

Is it possible to link each gallery thumbnail if i use the built in WordPress native gallery?
user avatar
3 votes
1 answer
3k views

Retrieving a custom link on an attachment

I wanted to link images in a gallery to a custom URL. I know I could add an extra field and do it this way I found this ticket on Trac, though, that modifies the "Link URL" field to accept custom ...
Jonathan Wold's user avatar
1 vote
1 answer
2k views

Gel all image from certain post type

I've found similar questions here, however I can't modify the answers to get images only from a certain post type - as the post type in those examples are "attachment" and not the name of a custom ...
elbatron's user avatar
  • 405
0 votes
1 answer
808 views

Any good lightbox-like option that works in WP 3.2.1?

I'm having problems finding a "plugin" that will help me display some of my images in a nice way such as prettyPhoto, Lightbox etc. As I'm already using the jQuery library, I'd prefer a plugin that ...
japanworm's user avatar
  • 567
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
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
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
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
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
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
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
3 votes
2 answers
4k views

Automatically add this attribute to the gallery shortcode

When inserting a gallery it adds the following shortcode: [gallery columns="6" ids="18,150,146,23,147,17,21,20,22"] I would like it to automatically add link="file" as the last attribute, whenever a ...
Alexnl's user avatar
  • 307
3 votes
2 answers
5k views

Add option to "Gallery Settings" section

I want to add a option to the "Gallery settings" (when you insert a gallery into a post). I once found some code on how to do this, but unfortunately I can't find it anymore. I can't even remenber if ...
xsonic's user avatar
  • 742
3 votes
2 answers
6k views

How do you modify the HTML output of a Gallery item (using the gallery shortcode)?

Im a bit lost on this simple problem so i thought id come and ask the pros. Ive just been told by my client that on their sites gallery, the name and description are on the same line. so for example ...
somdow's user avatar
  • 265
3 votes
1 answer
11k views

Making WordPress Gallery (.gallery-item) Responsive?

Shortcode for Gallery: [gallery link="file" columns="5" size="medium"] I’m using a 5 column gallery on an inner page of a website, obviously when the site responds down to mobile and even tablet ...
Tom25's user avatar
  • 73
2 votes
2 answers
4k views

Remove width and height attributes from [gallery] output

WordPress automatically adds the width and height attributes to [gallery] shortcode images. How to delete these attributes? Something like this but for [gallery] output.
mvod's user avatar
  • 95
0 votes
2 answers
7k views

How do I get gallery thumbnail URL and change the default thumbnail size?

when I create a gallery I get this code generated yet I can;t find out how <img width="150" height="150" src="http://localhost/wp2/wp-content/uploads/2012/06/28_0120-150x150.jpg" class="attachment-...
ilyo's user avatar
  • 356
0 votes
2 answers
20k views

ID of images from gallery

Does anyone know how to get ID's of images from wordpress gallery in post? I have search entire internet and there is nothing to this subject.
Itachi's user avatar
  • 149
0 votes
1 answer
2k views

conditional shortcode not working

I'm using a plugin, NextGEN gallery, to display photos. Each gallery from this plugin corresponds to a different sub-page, so I'm using conditional shortcodes to assign the right gallery to it's ...
user1255049's user avatar
0 votes
1 answer
10k views

Creating a gallery custom post type?

Hi I was wondering if it is possible to create a custom post type called "Gallery" where i only upload photos and ad captions and when i post it, it post as a gallery. Also when it shows on the ...
Terrell Anderson's user avatar
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
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
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
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
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
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
4 votes
1 answer
516 views

Build path for a custom portfolio plugin

I'm finishing up a personal site that I've spent many weekends on. I've left one of the (potentially) most complicated parts to the end of production. I'm looking for some advice on how to proceed ...
Bosworth99's user avatar
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
2 answers
8k views

Bulk edit wordpress images alt and title attributes

I uploaded around 600 pictures in different galleries in wordpress without setting the titles and alt attributes. I need to edit them, I was wondering a way to edit them by album, let's say the title ...
user avatar
3 votes
1 answer
462 views

Excludes posts that don't have attachments in the_content()

I'm trying to write a loop that excludes posts that don't have attachments in their content areas. I've got 200 posts in a custom post type called "students". I need to do a query of all students ...
Andrew Lazarus's user avatar
3 votes
1 answer
10k views

Change the output for [gallery] shortcode

I'm sorry if this question was answered here, but I couldn't find it. Is possible to change the HTML output of [gallery] shortcode (without plugins)? I would like to show the thumbnails as another ...
gregolin's user avatar
2 votes
3 answers
3k views

Define size for `get_post_gallery_images`, they seem to have been resized to 150x150

I'm using get_post_gallery_images and it's spitting images out as 150x150. It doesn't look like it takes a size parameter, so I assumed it would just spit out the largest image or preferably one of my ...
UzumakiDev's user avatar
2 votes
1 answer
532 views

Gallery images titles - get from post

Is there any possibility to make a functions hook, which will automatically override titles of added images (or added during gallery creation) with post title? Just like in the example: - im creating ...
Julia Galden's user avatar
2 votes
2 answers
575 views

Looking to display non-image files in Gallery with logo specific to file type

When I first began looking into this, File Gallery got me much closer to solving the problem. The only issue is that the plugin only displays the generic non-image icon when I upload a file. Does ...
Dan's user avatar
  • 897
2 votes
1 answer
560 views

The WordPress Gallery, Grabbing The Link and Images?

I have created a template for gallery named image.php which allows me to create a news website style image gallery that can be embedded in posts. But I need two more things to make this complete. ...
AndrettiMilas's user avatar
2 votes
1 answer
4k views

How to filter 'post_gallery' after all other filters/plugins etc

I'm trying to re-format the gallery output a bit, change default columns and link setting, as well as exclude the featured image from the gallery images. I can use *add_filter('post_gallery' ...)* in ...
Mere Development's user avatar
2 votes
1 answer
461 views

How do I change the gallery that is inserted in the post?

When I insert a gallery to a blog post using the [gallery] shortcode or simply the insert media button I get a default structured gallery in my blog through the_content(); However the gallery comes ...
ilyo's user avatar
  • 356