• I have a very simple PHP code which does a circular crop for the gravatar.

    In the loop, the code is being executed like so:

    <img src="<?php echo crop_avatar(get_avatar(get_the_author_ID(), 200)); ?>" width="85" height="85">
    
    <?php
    
       // Sends the gravatar path to image.php
       function crop_avatar($path) {
    
          preg_match("/src='(.*?)'/i", $path, $matches);
    
          return get_template_directory_uri() . "/image.php?path=". $matches[1];
       }
    
    ?>

    and in PHP the code would be something like this

    if(isset($_GET['path'])) {
    
        $path = $_GET["path"];
        $image = imagecreatefromjpeg($path);
    
        $width = imagesx($image);
        $height = imagesy($image);
                // CircleCrop class is just a simple PHP GD image manipulation
        $crop = new CircleCrop($image,$width,$height);
    
                // Convert the header to PNG
        $crop->crop()->display();
    
    }

    anybody has any ideas? please..

Viewing 11 replies - 1 through 11 (of 11 total)
  • Thread Starter bebensiganteng

    (@bebensiganteng)

    the link

    Thread Starter bebensiganteng

    (@bebensiganteng)

    Look at your entry. How could anybody know what to say or do from what you have written??

    Like, WHAT KIND OF ERROR? How about really describing the ERROR??

    Step-by-step explain what you were trying to do.
    Explain why the “internal error” message led you to this code.

    Help people to help you.

    Thread Starter bebensiganteng

    (@bebensiganteng)

    The error is mentioned on the title (Internal Server Error 500, just in case anybody miss it) and the error happens when the above code is implemented.

    there is nothing else beside that code which causes the error.

    Without access to your servers error logs it’s impossible to say where the error is, but at a (very vague) guess I’d say that something in your CircleCrop class isn’t doing what it’s supposed to. If you look at your error logs you’ll be able to see more information.

    If it was me, I’d forget about trying to add rounded corners into a gravatar like that. As you’ve seen there’s issues when you code something like that and it’s not needed. All you need to do is set up a CSS style rule in your theme to show the gravatar images with rounded corners.

    As an example from this forum here (your CSS identifiers may change…):

    img.photo.avatar {
        border-radius: 10px;
        -moz-border-radius: 10px;
        -webkit-border-radius: 10px;
    }

    In an ideal world you should only need border-radius but in the “real world” you need to make allowances for the -moz and -webkit settings as well.

    That’s all it is, and the corners on all gravatar images will be rounded by 10 pixels. No PHP, no errors and no extra coding.

    for starters we’re going to need to know what kind of system are you on; Apache, IIS, Lighttpd? do you have any sort of management panel such as cPanel or plesk?

    Typically 500 errors come in 2 varieties, the server generated type and the CMS generated type. In my experience, most all 500 errors from WP are of the server type and therefore will log in your apache error log file.

    If you are on a linux maching you can find this file typically by doing something similar to this:

    [[email protected] /]# find / -name apache||httpd||error.log

    Now this is more than likely going to output more than one file, however what you’re looking for is your main httpd log file.

    This is assuming that you are on a linux system will shell access however, which may not be the case.

    Also, this is a side note, but i’m pretty sure what you mean by this:
    Preg_match("/src='(.*?)'/i",

    is actually supposed to be:
    reg_match(“/src='(*.?)’/i”,

    though I am not 100% sure, it seems to me the way you have it is looking for file extensions rather than the file name itself.

    Thread Starter bebensiganteng

    (@bebensiganteng)

    ow CSS3, i’m trying to avoid that since it has to work on ie7.. but maybe there’s a plug for that.

    thanks

    Not sure exactly what your trying to do, but I think border-radius is supported in IE7? if so:

    .reference-element {
    border-radius: 10px;
    }

    of course changing reference-element to your actual image.
    *not tested yet*

    I have not used this in a very long time, but I know that at some point in time you could use the rounded corners directive, something like:

    rounded-corner: value-here...
    }

    You can try it out using a browser emulation plugin, chrome and firefox both have plugins for this.

    Is there a reason that you’re trying to support a browser that’s 3 versions behind the current release? Even Google’s planning on dripping support for IE8 soon… https://www.pcmag.com/article2/0,2817,2409768,00.asp

    I do understand that some customers do want out-dated things like this so I can understand it in some cases.

    If you have to stick with doing it programatically, go back and look at the error logs of your server to see where the problem is. When you find that you’ll be able to see exactly where the problem is and what’s causing it. Until you do that no one cna help you to fir whatever the problem is.

    Thread Starter bebensiganteng

    (@bebensiganteng)

    yeah, I’ve read that but I personally think we can completely abandon old IE just yet, at least not from ie7 and up.

    But anyway I’ve found a plug https://css3pie.com/ haven’t tried it yet but looks promising, other way is using canvas there’s a plug for IE as well.

    I’m going to ditch the PHP method, its taking too much time to fix the problem.

    thanks!

    Personally, I’m seeing IE7 usage at around 4-5% of visitors. For me, that is not enough of a demographic for me to put so much time and effort into making a rounded corner on an external image. Anyone that’s still uisng IE7 wouldn’t see the difference in the design and I’d be wasting… how long have you been trying to do this for so far???

    You can try to code around it using that system that you’ve found (which actually looks like it’s pretty good) but how much more time are you going to spend on it? If I spent that much time on something that small and really insignificant I’d be asked very firmly to explain why I’ve done that when I could have spent my time doing something a lot more productive – and I work in a graphic design studio where the look is everything.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Internal Server Error with WordPress and PHP’ is closed to new replies.