Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

just returns original image? #20

Open
alvarix opened this issue Jan 9, 2014 · 3 comments
Open

just returns original image? #20

alvarix opened this issue Jan 9, 2014 · 3 comments

Comments

@alvarix
Copy link

alvarix commented Jan 9, 2014

$url = $job->getLogoUrl() ;   // Required
$width = 100;                                                                  // Optional. Defaults to '150'
$height = 50;                                                                 // Optional. Defaults to '150'
$crop = true;                                                                  // Optional. Defaults to 'true'
$retina = false;                                                               // Optional. Defaults to 'false'

// Call the resizing function (returns an array)
$image = matthewruddy_image_resize( $url, $width, $height, $crop, $retina );
if ( is_wp_error( $image ) ) {
    echo $image->get_error_message() ;       // Displays error message returned from resizing function
 } else {
   $img = $image['url'];
   echo "<img src='$img' alt='Logo' />";
  }
@jplew
Copy link

jplew commented Feb 4, 2014

I'm having the same problem. print_r($image) is returning an array with only three elements: the original image url, and the width and height. It's missing the ''type'' value.

I tried using the built-in error reporting, but it is not reporting any errors.

Even when I intentionally break the URL, it doesn't report any error.

I had it working earlier, it just broke all of a sudden.

@shadle10
Copy link

I ran into this issue and it worked for me when I commented out lines 226 to 229 and lines 315 to 319 on resize.php. If your installation matches the first condition though you would likely comment out lines 91 to 94 and 140 to 144 (although I haven't tested this). The problem that I ran into was that the images were not in the media library so when that happens the normal sized image is returned from the matthewruddy_image_resize function. When you comment out those lines though it forces a resized image to be created.

@Yeasir
Copy link

Yeasir commented Oct 18, 2014

Though, it is late, but i have found a solution, hope this will help others. The problem is on these lines (53-55)
// Get the image file path
$file_path = parse_url( $url );
$file_path = $_SERVER['DOCUMENT_ROOT'] . $file_path['path'];

Actually $_SERVER['DOCUMENT_ROOT'] should return something like this '/home/public_html/', but sometime on some server misconfiguration it returns like this '/usr/local/apache/htdocs', then it does not work on the file system and thus the image file is not found by wordpress. So we get wp error on this block(104-107),
// Load Wordpress Image Editor
$editor = wp_get_image_editor( $file_path );
if ( is_wp_error( $editor ) )
return array( 'url' => $url, 'width' => $width, 'height' => $height );

thus returns only the url, width, height.
Now, for the solution, we can use two approach,

  1. Asking server service provider to fix settings so it returns expected result on $_SERVER['DOCUMENT_ROOT'], more info here http://stackoverflow.com/questions/15489672/php-shared-hosting-interpretation-of-serverdocument-root?rq=1
  2. We can replace the $_SERVER['DOCUMENT_ROOT'] block with these codes, here's what i have used in my case
    // Get the image file path
    $file_path = parse_url( $url );
    $file_path['path'] = str_replace("/~pacifiq5/domes/", "", $file_path['path']);
    $file_path = ABSPATH . $file_path['path'];
    yes, you might need to remove some duplicated text as 2nd line because wordpress ABSPATH may already include that part of the url. Use var_dump($file_path['path'] ) or return[$file_path['path']] to find what's that duplicated part.
    Finally, sorry for my bad English.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants