<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
    <title></title>
  </head>
  <body text="#000000" bgcolor="#ffffff">
    Here's what I do for dynamic layouts on the front end.&nbsp; I don't use
    $content_width for this.&nbsp; I filter 'embed_defaults' to handle embeds
    because this is where the problems arise.&nbsp; For images or anything
    else, you can use CSS.<br>
    <br>
    The basic functionality would be something like:<br>
    <br>
    =======<br>
    <br>
    add_filter( 'embed_defaults', 'my_embed_defaults' );<br>
    <br>
    function my_embed_defaults( $args ) {<br>
    <br>
    &nbsp;&nbsp;&nbsp; $layout = my_get_layout_function();<br>
    <br>
    &nbsp;&nbsp;&nbsp; if ( '1-column' == $layout )<br>
    &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $args['width'] = 900;<br>
    <br>
    &nbsp;&nbsp;&nbsp; elseif ( '2-columns' == $layout )<br>
    &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $args['width'] = 600;<br>
    <br>
    &nbsp;&nbsp;&nbsp; return $args;<br>
    }<br>
    <br>
    ======<br>
    <br>
    On 8/10/2011 2:25 PM, Chip Bennett wrote:
    <blockquote
cite="mid:CAPdLKqco-LCuqJjn_K=+AqoLgb9T+dFQ4AR8Q30GHLS=dr+O2w@mail.gmail.com"
      type="cite">Okay, one more stab at this.
      <div><br>
      </div>
      <div>First, I'm hooking oenology_set_content_width() into two
        hooks, one on the front end, and one on the back end:</div>
      <div><br>
      </div>
      <blockquote class="webkit-indent-blockquote" style="margin: 0pt
        0pt 0pt 40px; border: medium none; padding: 0px;">
        <div>
          <div>add_action( 'wp_head', 'oenology_set_content_width' );</div>
          <div>add_action( 'admin_init', 'oenology_set_content_width' );</div>
        </div>
      </blockquote>
      <div><br>
      </div>
      <div>Second, I changed oenology_get_current_page_layout() to
        accommodate both contexts:</div>
      <div><br>
      </div>
      <blockquote class="webkit-indent-blockquote" style="margin: 0pt
        0pt 0pt 40px; border: medium none; padding: 0px;">
        <div>
          <div>function oenology_get_current_page_layout() {</div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>global
            $post, $oenology_options;</div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>$custom
            = ( get_post_custom( $post-&gt;ID ) ? get_post_custom(
            $post-&gt;ID ) : false );</div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>$custom_layout
            = ( isset( $custom['_oenology_layout'][0] ) ?
            $custom['_oenology_layout'][0] : 'default' );<span
              class="Apple-tab-span" style="white-space: pre;"> </span></div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>$layout
            = '';</div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>if
            ( ! is_admin() ) {</div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>if
            ( is_page() ) {</div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>if
            ( 'default' == $custom_layout ) {</div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>$layout
            .= $oenology_options['default_static_page_layout'];</div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>}
            else {</div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>$layout
            .= $custom_layout;</div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>}
            else if ( is_single() ) {</div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>if
            ( 'default' == $custom_layout ) {</div>
          <div>
            <span class="Apple-tab-span" style="white-space: pre;"> </span>$layout
            .= $oenology_options['default_single_post_layout'];</div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>}
            else {</div>
          <div>
            <span class="Apple-tab-span" style="white-space: pre;"> </span>$layout
            .= $custom_layout;</div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>}
            else if ( is_home() || is_archive() || is_search() ||
            is_404() ) {</div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>$layout
            .= $oenology_options['post_index_layout'];</div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>}
            else if ( is_admin() ) {</div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>if
            ( 'page' == $post-&gt;post_type ) {</div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>if
            ( 'default' == $custom_layout ) {</div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>$layout
            .= $oenology_options['default_static_page_layout'];</div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>}
            else {</div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>$layout
            .= $custom_layout;</div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>}
            else if ( is_single() ) {</div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>if
            ( 'post' == $post-&gt;post_type ) {</div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>$layout
            .= $oenology_options['default_single_post_layout'];</div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>}
            else {</div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>$layout
            .= $custom_layout;</div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
          <div><span class="Apple-tab-span" style="white-space: pre;"> </span>return
            $layout;</div>
          <div>}</div>
        </div>
      </blockquote>
      <div><br>
      </div>
      <div>I *think* this covers all bases?</div>
      <div><br>
      </div>
      <div>I would love to hear anyone's thoughts on best practices
        here!</div>
      <div><br>
      </div>
      <div>Chip<br>
        <br>
        <div class="gmail_quote">
          On Wed, Aug 10, 2011 at 1:55 PM, Chip Bennett <span dir="ltr">&lt;<a
              moz-do-not-send="true" href="mailto:chip@chipbennett.net">chip@chipbennett.net</a>&gt;</span>
          wrote:<br>
          <blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt
            0.8ex; border-left: 1px solid rgb(204, 204, 204);
            padding-left: 1ex;">
            It definitely impacts large images and oembeds on the front
            end. So, setting it *only* in the Admin side wouldn't help
            with those.
            <div><br>
            </div>
            <div>Question: what if there was one *global* set (e.g.
              using the largest width), and then a front-end override
              (e.g. using my original function)? There's nothing
              preventing that, is there? Let me play around with it a
              bit. I want to figure out what is the best-practice
              implementation, while allowing for dynamic content width
              (primarily for display of large-size images, and embedded
              videos.</div>
            <div><br>
            </div>
            <font color="#888888">
              <div>Chip</div>
            </font>
            <div>
              <div class="h5">
                <div><br>
                  <div class="gmail_quote">On Wed, Aug 10, 2011 at 1:46
                    PM, Otto <span dir="ltr">&lt;<a
                        moz-do-not-send="true"
                        href="mailto:otto@ottodestruct.com"
                        target="_blank">otto@ottodestruct.com</a>&gt;</span>
                    wrote:<br>
                    <blockquote class="gmail_quote" style="margin: 0pt
                      0pt 0pt 0.8ex; border-left: 1px solid rgb(204,
                      204, 204); padding-left: 1ex;">
                      Consistency is something that happens to other
                      people.<br>
                      <br>
                      The $content_width is actually used for a lot of
                      things. It also<br>
                      controls the width of the fullscreen editor, for
                      example. It also<br>
                      controls the width used for oembed requests. It
                      controls the maximum<br>
                      value of the "large" image size when displayed in
                      the editor.<br>
                      <br>
                      So it definitely needs to be set globally. In
                      fact, it probably only<br>
                      needs to be set in the admin side, I don't think
                      it has much if any<br>
                      effect on the public facing side of the site.
                      Although I'm not sure<br>
                      about that, especially for the oembeds case.<br>
                      <font color="#888888"><br>
                        -Otto<br>
                      </font>
                      <div>
                        <div><br>
                          <br>
                          <br>
                          On Wed, Aug 10, 2011 at 1:35 PM, Chip Bennett
                          &lt;<a moz-do-not-send="true"
                            href="mailto:chip@chipbennett.net"
                            target="_blank">chip@chipbennett.net</a>&gt;
                          wrote:<br>
                          &gt; So what would be best practice here?
                          Perhaps setting it separately for<br>
                          &gt; is_admin(), and using the largest
                          $content_width value? Perhaps hooking it<br>
                          &gt; into admin_init?<br>
                          &gt; Also: why is $content_width used on
                          *insertion*, yet controlled by the<br>
                          &gt; *Theme*? That isn't intuitive. And,
                          wouldn't it potentially introduce issues<br>
                          &gt; whenever the Theme is changed *after*
                          insertion?<br>
                          &gt; Chip<br>
                          &gt;<br>
                          &gt; On Wed, Aug 10, 2011 at 10:22 AM, Otto
                          &lt;<a moz-do-not-send="true"
                            href="mailto:otto@ottodestruct.com"
                            target="_blank">otto@ottodestruct.com</a>&gt;
                          wrote:<br>
                          &gt;&gt;<br>
                          &gt;&gt; I've tried this sort of thing, and it
                          is *fraught* with peril.<br>
                          &gt;&gt;<br>
                          &gt;&gt; Make sure you test inserting content
                          into various posts and pages and<br>
                          &gt;&gt; such thoroughly. The content width is
                          used on content insertion, not<br>
                          &gt;&gt; just on content display.<br>
                          &gt;&gt;<br>
                          &gt;&gt; Basically, the media uploader expects
                          the content width to be set when<br>
                          &gt;&gt; images are uploaded and resized. If
                          you're only setting it on wp_head,<br>
                          &gt;&gt; your results may be unexpected for
                          various size values in the media<br>
                          &gt;&gt; section.<br>
                          &gt;&gt;<br>
                          &gt;&gt; -Otto<br>
                          &gt;&gt;
                          _______________________________________________<br>
                          &gt;&gt; theme-reviewers mailing list<br>
                          &gt;&gt; <a moz-do-not-send="true"
                            href="mailto:theme-reviewers@lists.wordpress.org"
                            target="_blank">theme-reviewers@lists.wordpress.org</a><br>
                          &gt;&gt; <a moz-do-not-send="true"
                            href="http://lists.wordpress.org/mailman/listinfo/theme-reviewers"
                            target="_blank">http://lists.wordpress.org/mailman/listinfo/theme-reviewers</a><br>
                          &gt;<br>
                          &gt;<br>
                          &gt;
                          _______________________________________________<br>
                          &gt; theme-reviewers mailing list<br>
                          &gt; <a moz-do-not-send="true"
                            href="mailto:theme-reviewers@lists.wordpress.org"
                            target="_blank">theme-reviewers@lists.wordpress.org</a><br>
                          &gt; <a moz-do-not-send="true"
                            href="http://lists.wordpress.org/mailman/listinfo/theme-reviewers"
                            target="_blank">http://lists.wordpress.org/mailman/listinfo/theme-reviewers</a><br>
                          &gt;<br>
                          &gt;<br>
_______________________________________________<br>
                          theme-reviewers mailing list<br>
                          <a moz-do-not-send="true"
                            href="mailto:theme-reviewers@lists.wordpress.org"
                            target="_blank">theme-reviewers@lists.wordpress.org</a><br>
                          <a moz-do-not-send="true"
                            href="http://lists.wordpress.org/mailman/listinfo/theme-reviewers"
                            target="_blank">http://lists.wordpress.org/mailman/listinfo/theme-reviewers</a><br>
                        </div>
                      </div>
                    </blockquote>
                  </div>
                  <br>
                </div>
              </div>
            </div>
          </blockquote>
        </div>
        <br>
      </div>
      <pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
theme-reviewers mailing list
<a class="moz-txt-link-abbreviated" href="mailto:theme-reviewers@lists.wordpress.org">theme-reviewers@lists.wordpress.org</a>
<a class="moz-txt-link-freetext" href="http://lists.wordpress.org/mailman/listinfo/theme-reviewers">http://lists.wordpress.org/mailman/listinfo/theme-reviewers</a>
</pre>
    </blockquote>
  </body>
</html>