<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[BuddyPress][5466] trunk: Deemphasizes sprintf() type 'alt' parameters for bp_core_fetch_avatar(), in order to avoid unnecessary database queries when loading avatars.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg > ul, #logmsg > ol { margin-left: 0; margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://buddypress.trac.wordpress.org/changeset/5466">5466</a></dd>
<dt>Author</dt> <dd>boonebgorges</dd>
<dt>Date</dt> <dd>2011-12-09 01:17:57 +0000 (Fri, 09 Dec 2011)</dd>
</dl>

<h3>Log Message</h3>
<pre>Deemphasizes sprintf() type 'alt' parameters for bp_core_fetch_avatar(), in order to avoid unnecessary database queries when loading avatars. Modifies calls throughout bp_core_fetch_avatar() so that they pass literal strings as 'alt' parameters. See <a href="http://buddypress.trac.wordpress.org/ticket/3806">#3806</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbpcorebpcoreavatarsphp">trunk/bp-core/bp-core-avatars.php</a></li>
<li><a href="#trunkbpmembersbpmembersadminbarphp">trunk/bp-members/bp-members-adminbar.php</a></li>
<li><a href="#trunkbpmembersbpmembersbuddybarphp">trunk/bp-members/bp-members-buddybar.php</a></li>
<li><a href="#trunkbpmembersbpmembersloaderphp">trunk/bp-members/bp-members-loader.php</a></li>
<li><a href="#trunkbpmembersbpmemberstemplatephp">trunk/bp-members/bp-members-template.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkbpcorebpcoreavatarsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core/bp-core-avatars.php (5465 => 5466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/bp-core-avatars.php        2011-12-08 21:08:01 UTC (rev 5465)
+++ trunk/bp-core/bp-core-avatars.php        2011-12-09 01:17:57 UTC (rev 5466)
</span><span class="lines">@@ -145,28 +145,28 @@
</span><span class="cx"> 
</span><span class="cx">         // Get item name for alt/title tags
</span><span class="cx">         $item_name = '';
</span><del>-
-        // Don't do this query if we don't have to
-        if ( !$alt || !$title ) {
</del><ins>+        
+        // Backpat for the 'alt' parameter, which used to encourage sprintf()-style values
+        if ( false !== strpos( $alt, '%s' ) || false !== strpos( $alt, '%1$s' ) ) {
+                var_dump( 'yes' );
</ins><span class="cx">                 if ( 'user' == $object )
</span><span class="cx">                         $item_name = bp_core_get_user_displayname( $item_id );
</span><span class="cx">                 elseif ( 'group' == $object )
</span><span class="cx">                         $item_name = bp_get_group_name( groups_get_group( array( 'group_id' =&gt; $item_id ) ) );
</span><span class="cx">                 elseif ( 'blog' == $object )
</span><span class="cx">                         $item_name = get_blog_option( $item_id, 'blogname' );
</span><ins>+                
+                $alt = sprintf( $alt, apply_filters( 'bp_core_avatar_alt', $item_name, $item_id, $object ) );
</ins><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if ( !$alt &amp;&amp; $item_name ) {
-                $alt = sprintf( __( &quot;Avatar Image: %s&quot;, 'buddypress' ), apply_filters( 'bp_core_avatar_alt', $item_name, $item_id, $object ) );
-        } elseif ( !$alt ) {
</del><ins>+        // Get a fallback for the 'alt' parameter        
+        if ( !$alt ) {
</ins><span class="cx">                 $alt = __( 'Avatar Image', 'buddypress' );
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        // Set title tag
</del><ins>+        // Set title tag, if it's been provided
</ins><span class="cx">         if ( $title )
</span><span class="cx">                 $title = &quot; title='&quot; . esc_attr( apply_filters( 'bp_core_avatar_title', $title, $item_id, $object ) ) . &quot;'&quot;;
</span><del>-        elseif ( $item_name )
-                $title = &quot; title='&quot; . esc_attr( apply_filters( 'bp_core_avatar_title', $item_name, $item_id, $object ) ) . &quot;'&quot;;
</del><span class="cx"> 
</span><span class="cx">         // Set CSS ID if passed
</span><span class="cx">         if ( !empty( $css_id ) )
</span></span></pre></div>
<a id="trunkbpmembersbpmembersadminbarphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-members/bp-members-adminbar.php (5465 => 5466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-members/bp-members-adminbar.php        2011-12-08 21:08:01 UTC (rev 5465)
+++ trunk/bp-members/bp-members-adminbar.php        2011-12-09 01:17:57 UTC (rev 5466)
</span><span class="lines">@@ -32,7 +32,8 @@
</span><span class="cx">                         'item_id' =&gt; bp_loggedin_user_id(),
</span><span class="cx">                         'email'   =&gt; $bp-&gt;loggedin_user-&gt;userdata-&gt;user_email,
</span><span class="cx">                         'width'   =&gt; 16,
</span><del>-                        'height'  =&gt; 16
</del><ins>+                        'height'  =&gt; 16,
+                        'alt'     =&gt; sprintf( __( 'Profile picture of %s', 'buddypress' ), bp_get_loggedin_user_fullname() )
</ins><span class="cx">                 ) );
</span><span class="cx"> 
</span><span class="cx">                 // Some admin bar setup in WP 3.2 differs from WP 3.3+.
</span><span class="lines">@@ -111,7 +112,8 @@
</span><span class="cx">                 'item_id' =&gt; bp_displayed_user_id(),
</span><span class="cx">                 'email'   =&gt; $bp-&gt;displayed_user-&gt;userdata-&gt;user_email,
</span><span class="cx">                 'width'   =&gt; 16,
</span><del>-                'height'  =&gt; 16
</del><ins>+                'height'  =&gt; 16,
+                'alt'          =&gt; sprintf( __( 'Profile picture of %s', 'buddypress' ), bp_get_displayed_user_fullname() )
</ins><span class="cx">         ) );
</span><span class="cx"> 
</span><span class="cx">         // Unique ID for the 'My Account' menu
</span></span></pre></div>
<a id="trunkbpmembersbpmembersbuddybarphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-members/bp-members-buddybar.php (5465 => 5466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-members/bp-members-buddybar.php        2011-12-08 21:08:01 UTC (rev 5465)
+++ trunk/bp-members/bp-members-buddybar.php        2011-12-09 01:17:57 UTC (rev 5466)
</span><span class="lines">@@ -69,7 +69,13 @@
</span><span class="cx"> 
</span><span class="cx">                         echo '&lt;li&gt;';
</span><span class="cx">                         echo '&lt;a href=&quot;' . bp_core_get_user_domain( $author-&gt;user_id, $author-&gt;user_nicename, $author-&gt;user_login ) . '&quot;&gt;';
</span><del>-                        echo bp_core_fetch_avatar( array( 'item_id' =&gt; $author-&gt;user_id, 'email' =&gt; $author-&gt;user_email, 'width' =&gt; 15, 'height' =&gt; 15 ) ) ;
</del><ins>+                        echo bp_core_fetch_avatar( array( 
+                                'item_id' =&gt; $author-&gt;user_id, 
+                                'email'   =&gt; $author-&gt;user_email, 
+                                'width'   =&gt; 15, 
+                                'height'  =&gt; 15, 
+                                'alt'     =&gt; sprintf( __( 'Profile picture of %s', 'buddypress' ), $author-&gt;display_name )
+                        ) );
</ins><span class="cx">                          echo ' ' . $author-&gt;display_name . '&lt;/a&gt;';
</span><span class="cx">                         echo '&lt;div class=&quot;admin-bar-clear&quot;&gt;&lt;/div&gt;';
</span><span class="cx">                         echo '&lt;/li&gt;';
</span></span></pre></div>
<a id="trunkbpmembersbpmembersloaderphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-members/bp-members-loader.php (5465 => 5466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-members/bp-members-loader.php        2011-12-08 21:08:01 UTC (rev 5465)
+++ trunk/bp-members/bp-members-loader.php        2011-12-09 01:17:57 UTC (rev 5466)
</span><span class="lines">@@ -178,7 +178,8 @@
</span><span class="cx">                 } elseif( bp_is_user() ) {
</span><span class="cx">                         $bp-&gt;bp_options_avatar = bp_core_fetch_avatar( array(
</span><span class="cx">                                 'item_id' =&gt; bp_displayed_user_id(),
</span><del>-                                'type'    =&gt; 'thumb'
</del><ins>+                                'type'    =&gt; 'thumb',
+                                'alt'     =&gt; sprintf( __( 'Profile picture of %s', 'buddypress' ), bp_get_displayed_user_fullname() )
</ins><span class="cx">                         ) );
</span><span class="cx">                         $bp-&gt;bp_options_title  = $bp-&gt;displayed_user-&gt;fullname;
</span><span class="cx">                 }
</span></span></pre></div>
<a id="trunkbpmembersbpmemberstemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/bp-members/bp-members-template.php (5465 => 5466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-members/bp-members-template.php        2011-12-08 21:08:01 UTC (rev 5465)
+++ trunk/bp-members/bp-members-template.php        2011-12-09 01:17:57 UTC (rev 5466)
</span><span class="lines">@@ -479,7 +479,7 @@
</span><span class="cx">                         'height' =&gt; false,
</span><span class="cx">                         'class' =&gt; 'avatar',
</span><span class="cx">                         'id' =&gt; false,
</span><del>-                        'alt' =&gt; __( 'Profile picture of %s', 'buddypress' )
</del><ins>+                        'alt' =&gt; sprintf( __( 'Profile picture of %s', 'buddypress' ), $members_template-&gt;member-&gt;fullname )
</ins><span class="cx">                 );
</span><span class="cx"> 
</span><span class="cx">                 $r = wp_parse_args( $args, $defaults );
</span><span class="lines">@@ -775,7 +775,7 @@
</span><span class="cx">                         'width'  =&gt; false,
</span><span class="cx">                         'height' =&gt; false,
</span><span class="cx">                         'html'   =&gt; true,
</span><del>-                        'alt'    =&gt; __( 'Profile picture of %s', 'buddypress' )
</del><ins>+                        'alt'    =&gt; sprintf( __( 'Profile picture of %s', 'buddypress' ), bp_get_loggedin_user_fullname() )
</ins><span class="cx">                 );
</span><span class="cx"> 
</span><span class="cx">                 $r = wp_parse_args( $args, $defaults );
</span><span class="lines">@@ -795,7 +795,7 @@
</span><span class="cx">                         'width'  =&gt; false,
</span><span class="cx">                         'height' =&gt; false,
</span><span class="cx">                         'html'   =&gt; true,
</span><del>-                        'alt'    =&gt; __( 'Profile picture of %s', 'buddypress' )
</del><ins>+                        'alt'    =&gt; sprintf( __( 'Profile picture of %s', 'buddypress' ), bp_get_displayed_user_fullname() )
</ins><span class="cx">                 );
</span><span class="cx"> 
</span><span class="cx">                 $r = wp_parse_args( $args, $defaults );
</span></span></pre>
</div>
</div>

</body>
</html>