Attachment link fixes from mdawaffe. fixes #3261
git-svn-id: http://svn.automattic.com/wordpress/trunk@4408 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
5d42dae380
commit
e04c8d972e
|
@ -122,12 +122,12 @@ function fix_attachment_links($post_ID) {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
$search = "# id=(\"|')p(\d+)\\1#i";
|
$search = "#[\s]+rel=(\"|')(.*?)wp-att-(\d+)\\1#i";
|
||||||
foreach ( $anchor_matches[0] as $anchor ) {
|
foreach ( $anchor_matches[0] as $anchor ) {
|
||||||
if ( 0 == preg_match($search, $anchor, $id_matches) )
|
if ( 0 == preg_match($search, $anchor, $id_matches) )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
$id = $id_matches[2];
|
$id = $id_matches[3];
|
||||||
|
|
||||||
// While we have the attachment ID, let's adopt any orphans.
|
// While we have the attachment ID, let's adopt any orphans.
|
||||||
$attachment = & get_post($id, ARRAY_A);
|
$attachment = & get_post($id, ARRAY_A);
|
||||||
|
@ -2007,11 +2007,11 @@ function the_attachment_links($id = false) {
|
||||||
<?php if ( $icon ) : ?>
|
<?php if ( $icon ) : ?>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row"><?php $thumb ? _e('Thumbnail linked to file') : _e('Image linked to file'); ?></th>
|
<th scope="row"><?php $thumb ? _e('Thumbnail linked to file') : _e('Image linked to file'); ?></th>
|
||||||
<td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo $post->guid; ?>" id="<?php echo $post->ID ?>"><?php echo $icon ?></a></textarea></td>
|
<td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo $post->guid; ?>"><?php echo $icon ?></a></textarea></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row"><?php $thumb ? _e('Thumbnail linked to page') : _e('Image linked to file'); ?></th>
|
<th scope="row"><?php $thumb ? _e('Thumbnail linked to page') : _e('Image linked to file'); ?></th>
|
||||||
<td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo get_attachment_link($post->ID) ?>" rel="attachment" id="<?php echo $post->ID ?>"><?php echo $icon ?></a></textarea></td>
|
<td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo get_attachment_link($post->ID) ?>" rel="attachment wp-att-<?php echo $post->ID; ?>"><?php echo $icon ?></a></textarea></td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php else : ?>
|
<?php else : ?>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -2020,7 +2020,7 @@ function the_attachment_links($id = false) {
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row"><?php _e('Link to page') ?></th>
|
<th scope="row"><?php _e('Link to page') ?></th>
|
||||||
<td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo get_attachment_link($post->ID) ?>" rel="attachment" id="<?php echo $post->ID ?>"><?php the_title(); ?></a></textarea></td>
|
<td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo get_attachment_link($post->ID) ?>" rel="attachment wp-att-<?php echo $post->ID ?>"><?php the_title(); ?></a></textarea></td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</table>
|
</table>
|
||||||
|
@ -2120,4 +2120,4 @@ function wp_load_image($file) {
|
||||||
return $image;
|
return $image;
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -221,7 +221,7 @@ addLoadEvent( function() {
|
||||||
display = 'full';
|
display = 'full';
|
||||||
|
|
||||||
if ( 'none' != link )
|
if ( 'none' != link )
|
||||||
h += "<a href='" + ( 'file' == link ? ( this.currentImage.srcBase + this.currentImage.src ) : ( this.currentImage.page + "' rel='attachment" ) ) + "' title='" + this.currentImage.title + "'>";
|
h += "<a href='" + ( 'file' == link ? ( this.currentImage.srcBase + this.currentImage.src ) : ( this.currentImage.page + "' rel='attachment wp-att-" + this.currentImage.ID + "'" ) ) + "' title='" + this.currentImage.title + "'>";
|
||||||
if ( display )
|
if ( display )
|
||||||
h += "<img src='" + ( 'thumb' == display ? ( this.currentImage.thumbBase + this.currentImage.thumb ) : ( this.currentImage.srcBase + this.currentImage.src ) ) + "' alt='" + this.currentImage.title + "' />";
|
h += "<img src='" + ( 'thumb' == display ? ( this.currentImage.thumbBase + this.currentImage.thumb ) : ( this.currentImage.srcBase + this.currentImage.src ) ) + "' alt='" + this.currentImage.title + "' />";
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue