0
votes

Whenever you create a new gallery in wordpress and add it to a post, it adds the appropriate shortcode. The problem I have with it is that by default the "link to" in the options before clicking "insert gallery", is set to "media file", but if you leave that as it is, and insert the gallery to the post, the shortcode doesn't actually include the link="media file" part, only when I hover on the gallery to edit it and re-save it, only then does it add link="media file".

If there is no "link" reference in the shortcode, by default the link is the image's post url, which is useless.

I want to make it so if there is no "link" set, that wordpress adds link="media file" by default.

Does anyone have any clue how can I inject that to the shortcode?

3

3 Answers

2
votes

try this:

1.) Navigating to the hidden WordPress Options page.

http://yoursite.com/wp-admin/options.php

2.) Locate the correct option

image_default_link_type

3.) Change the option to your desired setting

blank
file 
post

Removing any text in the field will set the Link To default to ‘None’ thus inserting images without any link.

File will change the default to link directly to the image file, allowing users to click the image and see it in a new tab/window, easily downloadable. Note that in our themes, if you have image protection turned on, even if you insert an image linking to the file, that link will be removed.

Post will link to the ‘Attachment Page’ in WordPress, which is basically a page that lists the details about your image, i.e. The Title, dimensions, etc.

After you’ve entered (or removed) the value you want to be as the new default for your site, simply scroll to the bottom of the page and hit the Save button. That’s it!

© http://rawfolio.com/overriding-wordpress-default-attachment-link-to-setting/

0
votes

You probably would need to create a plugin that removes the current gallery shortcode and replaces it with a custom one. The good news is you can just copy the current shortcode and add the code you need. There was an example of this on the support forums actually:

http://wordpress.org/support/topic/edit-gallery-shortcode

0
votes

This is a little bug in Wordpress 3.5.1 You can add the reference in your shortcode manually link="file" [gallery link="file" ids="xx,xx,xx"]

or when insertig the gallery go to the option and switch the selector from media file to attachment and then back to media file and it will be inserted automatically. It's a little bug.