• Resolved Rasso Hilber

    (@nonverbla)


    Hi there,

    your plugin looks very promising! I just have encountered one issue using it: Everything works fine with the generation of the grayscaled files in the uploads folder, but when I try to fetch the filtered image in my theme, it doen’t give me back the desired file. The suffix “-gray” is missing in the path.

    I’m using the function wp_get_attachment_image_src($id, "my_grayscale_image_size")

    Maybe it has something to do with how you are saving the image metadata on line 79 in grayscale.php? Unfortunately, I don’t know how to debug this script, since it runs in ajax…

    https://wordpress.org/plugins/grayscale/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Fabien Quatravaux

    (@fab1en)

    Hi

    If you used for example grayscale_add_image_size('my_grayscale_image_size', 300, 300, false, true) in your function.php, you have to use wp_get_attachment_image_src($id, "my_grayscale_image_size-gray") in your theme to get the grayscale picture.

    Thread Starter Rasso Hilber

    (@nonverbla)

    Hmm, I don’t know anymore what was exactly the problem, but after some tweaking in the code I worked it out. I think it was not working because of this line in your grayscale.php:

    $metadata['sizes'][$size.'-gray']['file'] = $result['file'];

    I changed it to

    $metadata['sizes'][$size]['file'] = $result['file'];

    and it works fine now.

    Plugin Author Fabien Quatravaux

    (@fab1en)

    Yes : you changed the implementation instead of changing the usage. The -gray is here intentionally. You can then easily implement a functionality where both original and grayscale image are used.

    Just call wp_get_attachment_image_src($id, "my_grayscale_image_size-gray") to have the grayscale image, and wp_get_attachment_image_src($id, "my_grayscale_image_size") to have to coloured one at the exact same size.

    Thread Starter Rasso Hilber

    (@nonverbla)

    Aaaah! Obviously I should learn how to read before starting to code 😉

    Thanks a lot for your patience! Topic resolved.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘correct image file is not fetched’ is closed to new replies.