Parse error: syntax error, unexpected T_STRING &&& flexible height?
Results 1 to 8 of 8

Thread: Parse error: syntax error, unexpected T_STRING &&& flexible height?

  1. #1
    Junior Member
    Join Date
    Apr 2012
    Posts
    4

    Parse error: syntax error, unexpected T_STRING &&& flexible height?

    So I have two issues, really.
    1. I want to have a fixed width of 590px, but a flexible height(whatever the height is determined to be by scaling the width to 590px). How do I achieve this?

    2. I'm receiving this error- Parse error: syntax error, unexpected T_STRING relating to these lines:
    PHP Code:
    add_theme_support'post-thumbnails' );  
    set_post_thumbnail_size590275true ); // 590 pixels wide by 275 pixels tall, hard crop mode
    add_image_size'following-post-thumbnails'250200true ); // 250 pixels wide by 200 pixels tall, hard crop mode 
    I'm sure it's something simple, my eyes just aren't yet trained to see it..

    Thanks.

  2. #2
    Pna lbh ernq guvf¿
    Join Date
    Jul 2004
    Location
    Kansas City area
    Posts
    19,348
    Welcome to PHPBuilder!

    Quote Originally Posted by achenn View Post
    1. I want to have a fixed width of 590px, but a flexible height(whatever the height is determined to be by scaling the width to 590px). How do I achieve this?
    Basic steps would be:
    1. Determine the height and width of the original image.
    2. Use simple algebra to determine the ratio of the new width (590px) to the old width.
    3. Multiply the old height by the above ratio to determine the new height.


    Quote Originally Posted by achenn View Post
    2. I'm receiving this error- Parse error: syntax error, unexpected T_STRING relating to these lines:
    There are no parse errors in the code snippet you posted. Make sure you're looking at the right location in the right source file.

  3. #3
    Junior Member
    Join Date
    Apr 2012
    Posts
    4
    Thanks for the quick response.

    1. With respect to the image height, it will vary depending upon the image used. I've scaled the images to have 590 widths in Wordpress, but this bit of code-
    PHP Code:
    add_theme_support'post-thumbnails' );  
    set_post_thumbnail_size590275true ); // 590 pixels wide by 275 pixels tall, hard crop mode
    add_image_size'following-post-thumbnails'590200true ); // 250 pixels wide by 200 pixels tall, hard crop mode 
    seems to be restricting the height to 275 and 200, respectively.

    2. The code I posted is what Coda determined to be around 154. Here is the full-
    PHP Code:
    <?php


    if ( ! isset( $content_width ) )
        
    $content_width  '590';


    /**
    * Add Menu Support
    **/

    add_theme_support('automatic-feed-links');
    register_nav_menu('main''Main Nav');

    /**
    * Add editor style - recommended according to Theme-Check
    **/
    add_editor_style('editor-style.css');


    /**
    * Add custom background    with custom background colour fix 
    * as shown here: http://devpress.com/blog/custom-background-fix-for-theme-developers/
    **/

    add_custom_background'grisaille_custom_background_callback' );

    function 
    grisaille_custom_background_callback() {

        
    /* Get the background image. */
        
    $image get_background_image();

        
    /* If there's an image, just call the normal WordPress callback. We won't do anything here. */
        
    if ( !empty( $image ) ) {
            
    _custom_background_cb();
            return;
        }

        
    /* Get the background color. */
        
    $color get_background_color();

        
    /* If no background color, return. */
        
    if ( empty( $color ) )
            return;

        
    /* Use 'background' instead of 'background-color'. */
        
    $style "background: #{$color};";

    ?>
    <style type="text/css">body { <?php echo trim$style ); ?> }</style>
    <?php

    }

    /**
    * Add custom header
    **/

    define('HEADER_TEXTCOLOR''334759');
    define('HEADER_IMAGE'''); // %s is the template dir uri
    define('HEADER_IMAGE_WIDTH'960); // use width and height appropriate for your theme
    define('HEADER_IMAGE_HEIGHT'200);

    // gets included in the site header

    function grisaille_header_style() {

        
    ?><style type="text/css">
            #site-title {
                background: url(<?php header_image(); ?>) 0 0 no-repeat;
                min-height: <?php echo HEADER_IMAGE_HEIGHT?>px;
                 margin: 20px 0;             
             }
            #site-title h1 a {
                 color:#<?php header_textcolor(); ?> ;
                 min-height: <?php echo HEADER_IMAGE_HEIGHT?>px;
            }
            #site-description {
                color:#<?php header_textcolor(); ?> ;
            }
             <?php if ( 'blank' == get_header_textcolor() ) { ?>
             #site-title h1 {
                 padding: 0;
             }
            #site-title h1 a  {
                display:block;
                text-indent:-99999px;
            }
            #site-description {
                display: none;
                text-indent:-99999px;
            }
                        
    <?php ?>
    </style>
    <?php
    }
    // gets included in the admin header
    function grisaille_admin_header_style() {
        
    ?>
            <style type="text/css">
                @font-face {
                font-family: 'WoodenNickelBlackRegular';
        src: url('<?php echo get_template_directory_uri(); ?>/type/WOODENNI-webfont.eot?') format('eot'),
             url('<?php echo get_template_directory_uri(); ?>/type/WOODENNI-webfont.woff') format('woff'),
             url('<?php echo get_template_directory_uri(); ?>/type/WOODENNI-webfont.ttf') format('truetype'),
             url('<?php echo get_template_directory_uri(); ?>/type/WOODENNI-webfont.svg#webfontDYhQeecV') format('svg');
        font-weight: normal;
        font-style: normal;
    }

            #headimg h1 {
                margin-bottom: 0;
            }
            #headimg h1 a{
                font:80px WoodenNickelBlackRegular, "Times New Roman", Times, serif;
                padding-left: 30px;
                text-transform:uppercase;
                text-decoration:none;
                width: <?php echo HEADER_IMAGE_WIDTH?>px;
                height: <?php echo HEADER_IMAGE_HEIGHT?>px;
            }
            #desc {
                font:26px  Geneva, Verdana, sans-serif;
                   padding-left: 30px;
            }
        </style><?php
    }
    add_custom_image_header('grisaille_header_style''grisaille_admin_header_style');

    /**
    * Change Excerpt length
    **/
    function grisaille_new_excerpt_length($length) {
        return 
    20;
    }
    add_filter('excerpt_length''grisaille_new_excerpt_length');

    /**
    * Change excerpt [...] to something else
    **/

    function grisaille_new_excerpt_more($more) {
        global 
    $post;
        return 
    ' ... <br /><a class="more-link" href="'get_permalink($post->ID) . __('">keep reading</a>''grisaille');
    }
    add_filter('excerpt_more''grisaille_new_excerpt_more');

    /**
    * Thumbnail support
    **/

    add_theme_support'post-thumbnails' );  
    set_post_thumbnail_size590275true ); // 590 pixels wide by 275 pixels tall, hard crop mode
    add_image_size'following-post-thumbnails'250200true ); // 250 pixels wide by 200 pixels tall, hard crop mode

    // THIS LINKS THE THUMBNAIL TO THE POST PERMALINK
    add_filter'post_thumbnail_html''grisaille_post_image_html'10);
    function 
    grisaille_post_image_html$html$post_id$post_image_id ) {

        
    $html '<a href="' get_permalink$post_id ) . '" title="' esc_attrget_post_field'post_title'$post_id ) ) . '">' $html '</a>';

        return 
    $html;
    }

    /**
    * Google font API - adding Ubuntu font
    **/
    function grisaille_enqueue_scripts_styles() {
                
    wp_enqueue_style'Marvel''http://fonts.googleapis.com/css?family=Marvel');                                                           
    }     
    add_action('wp_enqueue_scripts''grisaille_enqueue_scripts_styles'); 
     
    /**
    * checks if the visitor is browsing either a page or a post and adds the 
    * JavaScript required for threaded comments if they are
    **/
    function grisaille_queue_js(){
      if (!
    is_admin()){
        if ( 
    is_singular() AND comments_open() AND (get_option('thread_comments') == 1))
          
    wp_enqueue_script'comment-reply' );
      }
    }
    add_action('get_header''grisaille_queue_js');

    /**
    * register_sidebar()
    **/

    add_action'widgets_init''grisaille_register_sidebars' );

    function 
    grisaille_register_sidebars() {

        
    /* Register the 'primary' sidebar. */
        
    register_sidebar(
            array(
                
    'id' => 'grisaillesidebar',
                
    'name' => __'Grisaille Sidebar''grisaille' ),
                
    'description' => __'Main right sidebar.''grisaille' ),
                
    'before_widget' => '<div class="sidebaritem">',
                
    'after_widget' => '</div>',
                
    'before_title' => '<h3 class="widget-title">',
                
    'after_title' => '</h3>'
            
    )
        );

    }    

    /**
    * Load the Theme Options Page for social media icons
    */
    require_once ( get_template_directory() . '/inc/theme-options.php' );


    /**
    * Loads the theme's translated strings
    */

    add_action('after_setup_theme''grisaille_language_theme_setup');
    function 
    grisaille_language_theme_setup(){
        
    load_theme_textdomain('grisaille'get_template_directory() . '/lang');
    }    
    ?>
    Again, any help is appreciated.

  4. #4
    Pna lbh ernq guvf¿
    Join Date
    Jul 2004
    Location
    Kansas City area
    Posts
    19,348
    I didn't see any questions in your latest reply as far as the image sizing is concerned, so... what's your question? When you come up with one (or more?), you might consider posting it/them in a new thread.

    As for your parse error, there are still no syntax errors in the code you posted.

  5. #5
    Junior Member
    Join Date
    Apr 2012
    Posts
    4
    Relating back to #1 in my original post, I need to have images at a set width of 590 but with no predetermined height. Regardless of how I scale and size my images, it seems to get caught up by the few lines of php I referenced earlier.

    My question is- how do I specify a specific width without limiting height?

  6. #6
    Pna lbh ernq guvf¿
    Join Date
    Jul 2004
    Location
    Kansas City area
    Posts
    19,348
    Quote Originally Posted by achenn View Post
    how do I specify a specific width without limiting height?
    You'd do so by calculating what the new height should be based on the process I outlined above.

  7. #7
    Junior Member
    Join Date
    Apr 2012
    Posts
    4
    The solution I'm seeking needs to be responsive, more or less.
    For example, for post1 the height of an image may be 700px but for post2 the height of an image might be 1100px.

    If I change the rule, per your instructions, the rule will apply to all images giving them the same height. Right?

    Is there not an option to specify width while ignoring height?

  8. #8
    Pna lbh ernq guvf¿
    Join Date
    Jul 2004
    Location
    Kansas City area
    Posts
    19,348
    Quote Originally Posted by achenn View Post
    If I change the rule, per your instructions, the rule will apply to all images giving them the same height. Right?
    Well my "instructions" weren't necessarily 'How to change your PHP code' - it was more along the lines of how the calculation should be done in general.

    If you've got different maximum dimensions based on different conditions, then you'd obviously need to handle that in your code implementation (such as by determining the "max width/height" based on other parameters - e.g. which post the image is for, etc.).

    Quote Originally Posted by achenn View Post
    Is there not an option to specify width while ignoring height?
    No idea - you'd have to consult the documentation (assuming it exists) on the 'set_post_thumbnail_size' user-defined function (or else look at the implementation of it and see if you can determine whether it supports this use case).

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •