Make WordPress Core

Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#23298 closed defect (bug) (fixed)

Initial gallery 'Link to' setting not applied

Reported by: pokes's profile pokes Owned by: ryan's profile ryan
Milestone: 3.5.2 Priority: normal
Severity: normal Version: 3.5.1
Component: Gallery Keywords: has-patch commit
Focuses: Cc:

Description (last modified by SergeyBiryukov)

When inserting a new gallery in a post, the setting shown in the 'Link to' dropdown of the gallery settings is not applied. Changing the setting (even straight back to what it showed) causes it to be applied.

To demonstrate/reproduce:

  1. New Post.
  2. Add Media.
  3. Create Gallery.
  4. Create a New Gallery.
  5. Under Gallery Settings observe but don't touch the 'Link to' setting.
  6. Insert Gallery.
  7. Resulting gallery shortcode has no link=file or link=post regardless of the 'Link to' setting.

Attachments (3)

1-25-2013 6-53-34 PM.png (17.4 KB) - added by CBarrett123 12 years ago.
Link to Media File
1-25-2013 7-40-50 PM.png (15.2 KB) - added by CBarrett123 12 years ago.
Link to Attachment
23298.patch (1015 bytes) - added by SergeyBiryukov 12 years ago.

Download all attachments as: .zip

Change History (46)

@CBarrett123
12 years ago

Link to Media File

@CBarrett123
12 years ago

Link to Attachment

#1 @CBarrett123
12 years ago

I can confirm the bug reported by Pokes using Twelve Eleven with no plugins active.
If you generate a new Gallery using either freshly uploaded images, or existing images previously uploaded, and set the link to "Media File", it's dropping the link="file" rom teh shortcode. You end up with [gallery ids="1,2,3,4"].

During the Gallery generation step, or when editing the gallery after saving, if you toggle from link to "Media File" to link to "Attachment Page" and then back to link to "Media File", now the correct short code of [gallery link="file" ids="1,2,3,4"] is generated.

Cheers!

#2 @nacin
12 years ago

  • Milestone changed from Awaiting Review to 3.5.2

Is this in 3.5.1?

#3 @pokes
12 years ago

  • Cc pokes added

Yes, in 3.5.1

#4 @SergeyBiryukov
12 years ago

  • Description modified (diff)

#5 @SergeyBiryukov
12 years ago

23298.patch makes "Attachment Page" the default value, since it's actually the default behaviour of gallery_shortcode(), and declares it as such in wp.media.gallery.defaults.

We should probably also explicitly declare it in gallery_shortcode() defaults.

Last edited 12 years ago by SergeyBiryukov (previous) (diff)

#6 follow-ups: @nacin
12 years ago

Is this a problem in 3.5.0? I imagine not, then?

#7 in reply to: ↑ 6 ; follow-up: @DrewAPicture
12 years ago

Replying to nacin:

Is this a problem in 3.5.0? I imagine not, then?

I can reproduce the bug on 3.5. It defaults to no link attribute without deliberately switching the option first.

  • Create gallery, leave as 'Attachment Page', get [gallery ids="1,2,3"]
  • Edit gallery, change to 'Image Link', get [gallery link="file" ids="1,2,3"]
  • Edit gallery again, change to 'Attachment Page', get [gallery link="post" ids="1,2,3]

@SergeyBiryukov: 23298.patch doesn't apply cleanly as the media-template.php additions are already in place in both 3.5 and 3.5.1

#8 @DrewAPicture
12 years ago

I should mention that if the dropdown value isn't changed by say, a user setting, to the last-used setting, it's not as big of a deal because absent a link attribute, gallery images default to attachment page links anyway.

#9 in reply to: ↑ 6 @SergeyBiryukov
12 years ago

  • Keywords needs-patch added

Replying to nacin:

Is this a problem in 3.5.0? I imagine not, then?

The symptoms in 3.5.0 and 3.5.1 are different.

In 3.5.0, the (minor) issue is just that the default value (link="post") is not always removed from the shortcode as it should per [22715], since it's not explicitly declared in wp.media.gallery.defaults.

In 3.5.1, the (bigger) issue is that the default value (link="file") is not respected, unless you toggle the dropdown from "Media File" to "Attachment Page" and back. This was introduced in [23262].

Now I see that linking to media files as the default was intentional in [23262]. 23298.patch reverts that, so I guess a new patch is needed.

#10 in reply to: ↑ 7 @SergeyBiryukov
12 years ago

Replying to DrewAPicture:

23298.patch doesn't apply cleanly as the media-template.php additions are already in place in both 3.5 and 3.5.1

Only in 3.5, see the changes in [23262].

#11 follow-up: @danix1
12 years ago

I can also confirm problem in my installation of wordpress 3.5.1. It's odd, that when I select "Attachment Page" and than select back "Media File", the link="file" attribute is inserted well. But when I leave default "Media File" selected, it doesn't work. It seems, that there is same where missing default attribute in js, to insert link="file".

#12 @nacin
12 years ago

  • Version changed from 3.5 to 3.5.1

[23262] may have been done in error for galleries. The default for images is linking to the file; the default for galleries is linking to the attachment page. I didn't catch the latter, making [23262] a bit overzealous (which I realized, and is why I immediately questioned 3.5 versus 3.5.1 behavior). 23298.patch is therefore probably the correct fix.

#13 @SergeyBiryukov
12 years ago

  • Keywords has-patch added; needs-patch removed

#14 follow-ups: @helgatheviking
12 years ago

Probably isn't the place, but you should be able to have a link="none" where the gallery images don't link anywhere.

#15 in reply to: ↑ 14 @krembo99
12 years ago

Replying to helgatheviking:

Probably isn't the place, but you should be able to have a link="none" where the gallery images don't link anywhere.

I agree . and it is probably not the right place either , but while already meddling with the code , should´t there be also a "custom URL" option at this very same place ?

#16 follow-up: @helgatheviking
12 years ago

in the gallery shortcode, if you replace:

$link = isset($attr['link']) && 'file' == $attr['link'] ? wp_get_attachment_link($id, $size, false, false) : wp_get_attachment_link($id, $size, true, false);

with

if ( isset($attr['link']) && 'none' == $attr['link'] ) {
	$link = wp_get_attachment_image($id, $size, false, false);
} elseif ( isset($attr['link']) && 'file' == $attr['link'] ) {
	$link = wp_get_attachment_link($id, $size, false, false);
} else {
	$link = wp_get_attachment_link($id, $size, true, false);
}

a non-linking gallery is easily accomplished.

@krembo99 - I think a custom URL would be a lot more difficult to accomplish. Does every image link to the custom URL? Or does each image have a custom URL?

#17 @helen
12 years ago

#23390 was marked as a duplicate.

#18 in reply to: ↑ 16 @krembo99
12 years ago

  • Cc krembo99 added

Replying to helgatheviking:


@krembo99 - I think a custom URL would be a lot more difficult to accomplish. Does every image link to the custom URL? Or does each image have a custom URL?

When one uploads an image to the image gallery, there is already a custom URL option "Allows you to set a custom link URL for your inserted image to link to when clicked".

This option however , even when set upon upload, is not available when using said image in a gallery shortcode. IMHO it should be . It will allow a much desired flexibility to the gallery shortcode (just imagine a "posts gallery" ).
But like I mentioned before , it might not be the right place to mention it , and it might require a new enhancement ticket.
(This option is possibly achieved with some plugin / core modifications seen for example HERE)

Version 0, edited 12 years ago by krembo99 (next)

#19 in reply to: ↑ 14 ; follow-up: @SergeyBiryukov
12 years ago

Replying to helgatheviking:

Probably isn't the place, but you should be able to have a link="none" where the gallery images don't link anywhere.

Related: #18178

#20 in reply to: ↑ 19 ; follow-up: @helgatheviking
12 years ago

Replying to SergeyBiryukov:

Replying to helgatheviking:

Probably isn't the place, but you should be able to have a link="none" where the gallery images don't link anywhere.

Related: #18178

How do you do that!? I even posted on the other ticket and couldn't find it again. Then, I can't find anything in trac.

#21 @helgatheviking
12 years ago

@krembo - I don't think that link URL is saved anywhere, so you can't use it in the gallery shortcode.

Back to the initial ticket, I can confirm this on 3.5.1 as well.

#22 @helgatheviking
12 years ago

  • Cc helgatheviking@… added

#23 in reply to: ↑ 20 @DrewAPicture
12 years ago

Replying to helgatheviking:

How do you do that!? I even posted on the other ticket and couldn't find it again. Then, I can't find anything in trac.

Google site search is your friend :)

site:core.trac.wordpress.org search terms

#24 @glrss
12 years ago

  • Cc glrss added

I've noticed the same thing with 3.5.1 on installations I manage and also on WordPress.com.

#25 @pthomson87
12 years ago

  • Cc pthomson87 added

#26 in reply to: ↑ 11 @pthomson87
12 years ago

Hey Guys/Gals,

I'm still a little confused as to how I can set link="file" as the default value for galleries? I have no use for the link to attachments for single images or galleries.

Does anybody know how best to achieve this?

Thanks in advance,
Paul

Replying to danix1:

I can also confirm problem in my installation of wordpress 3.5.1. It's odd, that when I select "Attachment Page" and than select back "Media File", the link="file" attribute is inserted well. But when I leave default "Media File" selected, it doesn't work. It seems, that there is same where missing default attribute in js, to insert link="file".

#27 @SergeyBiryukov
12 years ago

  • Keywords commit added

#28 follow-up: @manyakabi
12 years ago

I agree with you. It's very annoying bug. The bug is still there. That's unbelievable, they don't distribute the new version. I think it's end of the WordPress.

#29 @pthomson87
12 years ago

Commit added? - Does this mean that the patch is being added for WP 3.5.2 release? It doesn't seem like it's fully resolved and likely be raised again in next release?

Not better to nip it in the bud now?

#30 @desrosj
12 years ago

  • Cc desrosj@… added

#31 @manyakabi
12 years ago

  • Cc manyakabi added

#32 @xavivars
12 years ago

  • Cc xavi.ivars@… added

#33 @greenshady
12 years ago

  • Cc justin@… added

#34 @mordauk
12 years ago

  • Cc pippin@… added

#35 in reply to: ↑ 28 @ghost1227
12 years ago

Replying to manyakabi:

I agree with you. It's very annoying bug. The bug is still there. That's unbelievable, they don't distribute the new version. I think it's end of the WordPress.

Seriously? WordPress is a massive project that is provided for your use free of charge. Bugs are constantly reported, features are suggested, and tweaks made to make your use of the platform easier... and you're going to say it's the end of WordPress because of something this inconsequential? Now, I have no direct affiliation with WordPress... in fact, I've yet to submit a patch to core, but this is just silly.

Be thankful that people are willing to dedicate the time and energy to this product to keep it alive. Be thankful that you are being given a solution that is as flexible and extensible as WordPress is for free. Give back to the community through finding bugs, suggesting features, or making otherwise useful comments. Dig into the forums if you have experience with plugins or themes... you'd be surprised how simple some questions are even for a regular user to answer. Dig into the bugtracker if you're a dev... every little bit of development support helps. If you don't think you're competent enough to do either of those things, then start off by reading this and leaving a word of encouragement or thanks to your favorite developer, or a random one, or the community as a whole.

tl;dr: Seriously? Don't complain about a free product that has a minor bug in it. It'll get fixed. Contribute if you can.

</endrant>

#36 @spaceda
12 years ago

if you do not need image to be linked to page you can use it: (found at support pages):

If you want to force the link to be directly to the image itself, go to around line 762-ish
where this code appears...

$link = isset($attr['link']) && 'file' == $attr['link'] ?
wp_get_attachment_link($id, $size, false, false) :
wp_get_attachment_link($id, $size, true, false);

Change it to just this...

$link = wp_get_attachment_link($id, $size, false, false);

You should get direct links to the big image after that.

regs

Last edited 12 years ago by spaceda (previous) (diff)

#37 @SergeyBiryukov
12 years ago

#24053 was marked as a duplicate.

#38 @DaganLev
12 years ago

  • Cc DaganLev added

#39 @SergeyBiryukov
12 years ago

#24086 was marked as a duplicate.

#40 @ryan
12 years ago

23298.patch seems to fix it for me.

#41 @ryan
12 years ago

Patch seem fine for trunk and the 3.5 branch. SergeyBiryukov, do you want to refresh anything with the patch?

#42 @ryan
12 years ago

  • Owner set to ryan
  • Resolution set to fixed
  • Status changed from new to closed

In 24161:

Respect the link to setting when inserting a gallery.

Props SergeyBiryukov
fixes #23298

#43 @ryan
12 years ago

In 24162:

Respect the link to setting when inserting a gallery.

Props SergeyBiryukov
fixes #23298 for 3.5

Note: See TracTickets for help on using tickets.