• Hey,

    met the portrait quality issue described in an other issue.

    After some digging, it seems to be caused by the fact that portrait photos that have a width of less than 768 (or 1024) and height of less or equal than 1024 pixels will not have image sizes ‘medium_large’ or ‘large’ generated for them. As codeneric\phmm\base\includes\Image::get_image() will only consider intermediate sizes, it will end up using the ‘medium’ size, which is by default set to 300 pixels. As a end result, a image with size of ~200×300 will end up being used which will appear blurry. The workaround for this is to use images that are larger than 768 pixels in width, or for slightly better results for modal display, images that are larger than the height OR width set for large images (1024 by default).

    The issue of having images fall back to ‘medium’ when intentionally trying to save some space on the web server could be helped with allowing the codeneric\phmm\base\includes\Image::get_image() to use ‘full’ image size if only ‘medium’ and ‘thumbnail’ are available (if $available_uncropped_sizes does not contain ‘medium_large’ or ‘large’).

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author M.Sc. Denis Golovin

    (@denis_golovin)

    Hi aksl,

    thank you for the detailed description and the debugging. I will look into it and come back to you asap.

    Regards,
    Denis

    Thread Starter aksl

    (@aksl)

    Because there can be custom image sizes, perhaps this type of approach would work with codeneric\phmm\base\includes\Image::get_image().

    After line 29:

    $small_sizes_names = array("thumbnail", "medium");
    $small_sizes_count = \count(\array_intersect($uncropped_sizes_names, $small_sizes_names));

    Replace line 78 if (\count($mapped_sizes) === 0) { with:
    if (\count($mapped_sizes) === 0 || \count($mapped_sizes) <= $small_sizes_count) {

    Did a quick test and seemed to work. One additional thing that you might to consider is to label the “medium_large” as a “small” size, so that you will have full size when the gallery is displayed with 1-column view.

    • This reply was modified 4 years, 8 months ago by aksl.
    Thread Starter aksl

    (@aksl)

    On a further thought, you could just strip the condition together and always append the original size to the output, because the browser will decide the image via the srcset attribute. The only thing that should be added is the watermarking of original image. This would be the code for the relevant part, with the condition being commented out:

    //if (\count($mapped_sizes) === 0) {
      $width =
        \hacklib_cast_as_boolean(\array_key_exists("width", $imagedata))
          ? ((int) $imagedata[\hacklib_id("width")])
          : null;
      $height =
        \hacklib_cast_as_boolean(\array_key_exists("height", $imagedata))
          ? ((int) $imagedata[\hacklib_id("height")])
          : null;
      if (($width !== null) && ($height !== null)) {
        $url = \wp_get_attachment_url($id);
        // added: watermarking of the original image
        if (\hacklib_cast_as_boolean($watermark)) {
          $url = self::get_watermark_url($url, $query_args);
        }
        $url = Utils::get_protocol_relative_url($url);
        $mapped_sizes[] = array(
          "url" => $url,
          "width" => $width,
          "height" => $height,
          "name" => "original"
        );
      }
    //}

    Might cause some side effects(?), not sure if the ‘sizes’ array element of the get_image() response is used in other cases.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Suggestion: add ‘full’ to help quality issues with portraits’ is closed to new replies.