WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Crop tool not working (10 posts)

  1. cnever
    Member
    Posted 2 years ago #

    Hi

    I see this thread is closed.

    I have the exact same problem, and dit fix the gaps in my code but still the same thing is happening.

    Any other suggestions would be great.

    Thanks

  2. James Kirk
    Member
    Posted 2 years ago #

    Heya cnever,

    When you say you had the "...exact same problem..." does that mean you are using a custom made theme for your site? If so, did you check the spacing (gaps as they are called in that thread) in the functions.php AND any .php files (the code in those files) which might be called in the functions.php file?

    Let us know.

    Cheers!

  3. cnever
    Member
    Posted 2 years ago #

    Hi James

    custom made theme - yes
    Please see following code but according to me all gaps are gone? (both files)

    Sorry for the long code (cant remember if there was another place where I was suppose to paste this?

    <?php require_once('portfolio-type.php')?>
    <?php add_filter('excerpt_length', 'my_excerpt_length');
    function my_excerpt_length($length) {
    	return 25;
    }
    
    add_filter('excerpt_more', 'new_excerpt_more');
    
    function new_excerpt_more($text){
    	return ' ';
    }
    
    function portfolio_thumbnail_url($pid){
    	$image_id = get_post_thumbnail_id($pid);
    	$image_url = wp_get_attachment_image_src($image_id, 'screen-shot');
    	return $image_url[0];
    }
    
     if (function_exists('add_theme_support')) {
        add_theme_support('menus');
    	add_theme_support('post-thumbnails');
    } 
    
    //asigning class to thumbnail
    the_post_thumbnail('thumbnail', array('class' => 'gallery_image_expanded'));
    
    //remove admin rights
     function remove_menus()
    {
        global $menu;
        global $current_user;
        get_currentuserinfo();
    
        if($current_user->user_login == 'second admin')
        {
            $restricted = array(__('Posts'),
                                __('Media'),
                                __('Links'),
                                __('Pages'),
                                __('Comments'),
                                __('Appearance'),
                                __('Plugins'),
                                __('Users'),
                                __('Tools'),
                                __('Settings')
            );
    		add_filter( 'show_admin_bar', '__return_false' );
            end ($menu);
            while (prev($menu)){
                $value = explode(' ',$menu[key($menu)][0]);
                if(in_array($value[0] != NULL?$value[0]:"" , $restricted)){unset($menu[key($menu)]);}
            }// end while
    
        }// end if
    }
    add_action('admin_menu', 'remove_menus');
    
    //gets image path to display where ever
    function getImage($num) {
    global $more;
    $more = 1;
    $link = get_permalink();
    $content = get_the_content();
    $count = substr_count($content, '<img');
    $start = 0;
    for($i=1;$i<=$count;$i++) {
    $imgBeg = strpos($content, '<img', $start);
    $post = substr($content, $imgBeg);
    $imgEnd = strpos($post, '>');
    $postOutput = substr($post, 0, $imgEnd+1);
    $postOutput = preg_replace('/width="([0-9]*)" height="([0-9]*)"/', '',$postOutput);;
    $image[$i] = $postOutput;
    $start=$imgEnd+1;
    }
    if(stristr($image[$num],'<img')) { echo '<a href="'.$link.'">'.$image[$num]."</a>"; }
    $more = 0;
    }
    ?>
    <?php
    //debugging log
    if(!function_exists('_log')){
      function _log( $message ) {
        if( WP_DEBUG === true ){
          if( is_array( $message ) || is_object( $message ) ){
            error_log( print_r( $message, true ) );
          } else {
            error_log( $message );
          }
        }
      }
    }
    ?>
  4. cnever
    Member
    Posted 2 years ago #

    Here is the file called at the top

    <!--This page is to create post type in admin area-->
    
    <?php
    if (function_exists('add_theme_support')){
    	add_theme_support('post-thumbnails');
    	set_post_thumbnail_size(280,210,true);
    	add_image_size('screen-shot', 720,540);
    	}
    
    add_action('init', 'portfolio_register');
    
    function portfolio_register() {
    	$args = array(
    	'label' => __('Portfolio'),
            'singular_label' => __('Project'),
            'public' => true,
            'show_ui' => true,
            'capability_type' => 'post',
            'hierarchical' => false,
            'rewrite' => true,
    		'query_var'=> true,
    		'menu position' => null,
            'supports' => array('title', 'editor', 'thumbnail')
    		);
    	register_post_type('portfolio', $args);
    }
    
    register_taxonomy("project-type",
    		array("portfolio"),
    		array("hierarchical" => true,
    		"label" => "Project Types",
    		"singular_label" =>
    		"Project Type",
    		"rewrite" => true));  
    
    // custom meta box//
    add_action("admin_init", "portfolio_meta_box");// hook for admin/dashboard creation
    
    function portfolio_meta_box(){ //create the meta box
    	add_meta_box("projInfo-meta", "Project Options", "portfolio_meta_options", "Portfolio", "side", "low");
    	}
    
    function portfolio_meta_options(){    //calling the metabox and link to display
            global $post;
            if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) return $post_id;
            $custom = get_post_custom($post->ID);
            $link = $custom["projLink"][0];
    ?>
        <label>Link:</label><input name="projLink" value="<?php echo $link; ?>" />
    <?php
    }
    
    	add_action('save_post', 'save_project_link');   
    
    function save_project_link(){
        global $post;    
    
        if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ){
            return $post_id;
        }else{
            update_post_meta($post->ID, "projLink", $_POST["projLink"]);
        }
    } 
    
    //creating colums in the dashboard
    add_filter("manage_edit-portfolio_columns", "project_edit_columns");     
    
    function project_edit_columns($columns){
            $columns = array(
                "cb" => "<input type=\"checkbox\" />",
                "title" => "Project",
                "description" => "Description",
                "link" => "Link",
                "type" => "Type of Project",
            );    
    
            return $columns;
    	}
    
    add_action("manage_posts_custom_column",  "project_custom_columns");   
    
    function project_custom_columns($column){
            global $post;
            switch ($column)
            {
                case "description":
                    the_excerpt();
                    break;
                case "link":
                    $custom = get_post_custom();
                    echo $custom["projLink"][0];
                    break;
                case "type":
                    echo get_the_term_list($post->ID, 'project-type', '', ', ','');
                    break;
            }
    }    
    
    ?>
  5. cnever
    Member
    Posted 2 years ago #

    You will see there are gaps between the php tags but not when they close, or am I missing something?

  6. James Kirk
    Member
    Posted 2 years ago #

    Heya cnever,

    Nothing "jumps" out at me with that code, however, admittedly, I am still learning about hooks and actions and things. My trouble shooting tip, though, would be to ask if you have gone back to the default WordPress theme (making sure no adjustments or additions have been made to the functions.php file) and see if you are able to see the images in the cropping tool at that point. If so, clearly the challenge is in the custom theme.

    Let us know.

    Cheers! :)

  7. cnever
    Member
    Posted 2 years ago #

    HI

    Yip, because the 2011 standard theme works perfectly? But the thing is I did not change anything besides the theme files. I have a index,functions,header,2custom pages,product loop. But according to me those don't matter right? Only the functions is the one I would think that is important? But according to me the functions file does not control the admin area? I could be wrong just trying to narrow down the search because it is going to take forever to delete junks of code and see what happens.

    Because I am definitely not skilled enough to really know what I am deleting or looking for.

    Thanks for feedback in any case.
    ps: just deleted the whole funtions file form 2011 - still works the editor so it's not that file at all??

  8. cnever
    Member
    Posted 2 years ago #

    Hi

    Solution:
    Open my eyes and redo as said in this post
    **NO, NO, NO spaces at the top of the function file, and files called in at the top, even before the php tags, so no comments/hmtl comments etc.

    You would not believe me but I think I figured it out.
    Now please if any body knows this, it is a very simple question.
    Do you always have to put a the ; (semi-colon) after each line even if the line gets closed with php tag. Reason why I am asking I have seen code where this is not done at all and worked?
    But this could also just be my very "trained" eye not picking up the syntax in context if you know what I mean.

    Thanks for James giving me the idea to inspect/trouble shoot.

    If you look at the top where it is asking acquire there is no semi colon, that was issue number 1 (although testing it now again this does not make a difference wow?)
    Issue number 2 was the comment before my php tag starts must be deleted completely and comment inside php tag.

    So conclusion is I am stupid, anyway thanks for the direction James.
    Cheers

    PS: do have a question regarding how to better manage the thumbnail look/cropping - code or in backend?

    Thanks

  9. James Kirk
    Member
    Posted 2 years ago #

    Heya cnever,

    No reason whatsoever to consider yourself anything other than one with slightly less experience with all this. We all learn new stuff every day (hopefully! I know I do!!)

    Yeah, it was hard to determine the spacing issues at the beginning of the code that was inserted here. As to the commented section at the top of the portfolio-type.php page, I (ahem) assumed you had put that in when you inserted the code to this page.

    Good for you, good for you. As to your question:

    PS: do have a question regarding how to better manage the thumbnail look/cropping - code or in backend?

    may I suggest you create a new post in the appropriate forum?

    Cheers! :)

  10. cnever
    Member
    Posted 2 years ago #

    Hi

    Yip I figured that it would be a new post. But think I know the solution to it - just a plugin. But I like customized stuff so much.

    Any case thanks again.

Topic Closed

This topic has been closed to new replies.

About this Topic