[wp-trac] [WordPress Trac] #22101: Gallery shortcode with link="file" is not linking the file in the RSS feed
WordPress Trac
noreply at wordpress.org
Sat Oct 27 15:11:19 UTC 2012
#22101: Gallery shortcode with link="file" is not linking the file in the RSS feed
--------------------------+------------------------------
Reporter: ifrins | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Feeds | Version: 3.4.2
Severity: normal | Resolution:
Keywords: |
--------------------------+------------------------------
Comment (by mdgl):
This happens because for some reason the gallery shortcode deliberately
generates completely different output for feeds. In file `wp-
includes/media.php` the function `gallery_shortcode()` contains the
following lines:
{{{
if ( is_feed() ) {
$output = "\n";
foreach ( $attachments as $att_id => $attachment )
$output .= wp_get_attachment_link($att_id, $size, true) .
"\n";
return $output;
}
}}}
Why it would want to do this is anybody's guess! Maybe it's just a
hangover from the days of the limited functionality of early feed readers.
In any case, as I hope you can see, the code doesn't reference the gallery
`link` option at all.
There appear to be two options to fix the problem. Firstly, we could just
delete the block of code above and allow feed output to contain the full
gallery HTML/CSS as though it was a normal page. Alternatively, we could
modify the code above to respect the value of the gallery `link` option,
something like the following (note this has not been tested - it's just a
suggestion, but based on similar code that occurs later on in the gallery
shortcode function):
{{{
if ( is_feed() ) {
$output = "\n";
$permalink = !isset($attr['link']) || 'file' != $attr['link'];
foreach ( $attachments as $att_id => $attachment )
$output .= wp_get_attachment_link($att_id, $size,
$permalink) . "\n";
return $output;
}
}}}
What do you think? What should be the correct behaviour of the gallery
within feeds?
--
Ticket URL: <http://core.trac.wordpress.org/ticket/22101#comment:2>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list