Jump to content
RicknRoller

Resized image sometimes not showing up

Recommended Posts

Hi there!

I am quite new to processwire and am just finishing my first PW project. I think the whole framework is awesome and could profit a lot from all the tutorials available. One thing that I somehow can't seem to get my head around is working with images and their resizing. I have following scenario:

A 'gallery-index' page with its 'gallery' children. Those children have an 'images' field where the user uploads his (often too big) images.

I am working with twig. On the gallery page frontend I have a slider, a displayed collection of all the images and a hidden one where I get the source to the original image in a popup. So in total the images will be outputted 3 times in different sizes.

First:

<div id="slick">
    {% for img in page.images %}
        <img src="{{ img.height(400).url }}" alt="">
    {% endfor %}
</div>

Second:

<div class="gallery">
    {% for img in page.images %}
        <img src="{{ img.width(300).url }}" alt="">
    {% endfor %}
</div>

Third:

<div class="hidden">
    {% for img in page.images %}
        <a href="{{ img.maxWidth(1024).url }}" data-original="{{ img.url }}"></a>
    {% endfor %}
</div>

Now, the loops basically work, and some images are displayed the right way. But not all of there are displayed at all, despite them being there in the DOM. The urls all look right but some will be displayed and some url just go to a small black box image. How comes that PW manages to have different results in displaying the images in different formats?

URL of gallery: http://2019.hclaupersdorf.ch/fotos/hc-laupersdorf-vs-ruschlikon-chiefs/ (there are more in the DOM than displayed)
URL of 'not working' image: http://2019.hclaupersdorf.ch/site/assets/files/2361/20180616-rueschlikon-21_42049612175_o.300x0.jpg

Furthermore, whenever this error occurs (which usually is at every page request on the gallery page), the DOM doesn't fully load. My JS for init the slider or the popup won't be loaded and the page is basically displayed half-loaded.

Any ideas or suggestions on how to work around it, best practice when handling images & galleries?

Thanks!

Share this post


Link to post
Share on other sites

When I inspect your page, no JS is being loaded at all. This doesn't have to do with PW per se. You're responsible for handling all the frontend assets correctly. (when I say "you", I mean the site-developer. The CMS just delivers what you tell it to.)

Go back to the drawing board and make sure your HTML, CSS + JS setup is correct. Perhaps there's a missing include() or you've disabled a prepend or append .php file?

  • Like 1

Share this post


Link to post
Share on other sites
14 minutes ago, dragan said:

When I inspect your page, no JS is being loaded at all. This doesn't have to do with PW per se. You're responsible for handling all the frontend assets correctly. (when I say "you", I mean the site-developer. The CMS just delivers what you tell it to.)

Go back to the drawing board and make sure your HTML, CSS + JS setup is correct. Perhaps there's a missing include() or you've disabled a prepend or append .php file?

Yes, the page doesn't fully load. Something goes wrong somewhere.

I restored my previous testgallery to show how it should work: http://2019.hclaupersdorf.ch/fotos/testgallery-iron-maiden/

I figure it has something to do with the images in the gallery being to many (33) or too large?

Thank you 🙂

Share this post


Link to post
Share on other sites
13 hours ago, RicknRoller said:

I figure it has something to do with the images in the gallery being to many (33) or too large?

No. In your Iron Maiden test gallery you load 4 JS files. You don't load them in your gallery you referred to in your first post. Check your template setup, your include/require setup etc. and make sure all frontend assets (css/js) are being loaded in your page(s).

Share this post


Link to post
Share on other sites

I am aware that the scripts are not loaded in the faulty gallery. The template is the same as in the working one, just the content in the page field 'images' is different. It is just as if php stopped working while executing and then omits further rendering of the DOM. There should also be a footer and many more scripts, it just kind of aborts the PHP at a certain point.

Share this post


Link to post
Share on other sites

@RicknRoller, did you check the server response for these damaged images? Its always 42 bytes for exactly this string: This is intentionally invalid image data.

Since the server replies with 200 I guess this is the content of the converted image file (you may want to check the folder /site/assets/files/2361/ for example).

If the file on your server is correct, then I'd check nginx, if the file contains this string, there is an issue with image conversion for some reason. Sounds like some sort of shareware limitation...

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By EyeDentify
      Hello Dear PW Gurus.

      Hope you fair well in these Corona Crisis times.

      Anyhow, i have a problem with a Cryptic error message that shows up when i am trying to Delete images out of a Images field.
      The Error message does say a little but it does not make sense to me why i can´t delete the images because of it.

      Is it some permission issue perhaps?

      I will attach screenshots of it and what i did prior to it.
      I am from sweden so ignore the funny words here and there.

      Hope you all can send me on the right track.
      i am running PW 3.0.139 on this install.

      Step1:

      Step 2: Select the images with the trashcan symbol

       
      Step 3: Cryptic Error message

      I am scratching my head on this one, have not seen this before.

      Thankfull for all help.
      /EyeDentify
    • By Guy Incognito
      This short script loops through some images from an XML feed and pushes new ones to an image field. It all works perfectly, except for some reason the last image (only) in the loop each time doesn't receive the image description... can everyone spot why? TIA! 🙂 
      foreach ($propertyImages as $img) { $fileName = trim($img[0]); if ( !empty($fileName) ) { $imgPath = '../property_data/'.$fileName; if(file_exists($imgPath) && !in_array(strtolower($fileName),$currentImages)) { $p->property_images->add($imgPath); $p->save(); $newImg = $p->property_images->last(); $newImg->description = $img[1]; $p->save(); } } }  
    • By Robin S
      Add Image URLs
      Allows images/files to be added to Image/File fields by pasting URLs.

      Usage
      Install the Add Image URLs module.
      A "Paste URLs" button will be added to all image and file fields. Use the button to show a textarea where URLs may be pasted, one per line. Images/files are added when the page is saved.
       
      https://github.com/Toutouwai/AddImageUrls
      https://modules.processwire.com/modules/add-image-urls/
    • By gebeer
      Hello all,
      sharing my new module FieldtypeImageReference. It provides a configurable input field for choosing any type of image from selectable sources. Sources can be: 
      a predefined folder in site/templates/ and/or a  page (and optionally its children) and/or the page being edited and/or any page on the site CAUTION: this module is under development and not quite yet in a production-ready state. So please test it carefully.
      UPDATE: the new version v2.0.0 introduces a breaking change due to renaming the module. If you have an older version already installed, you need to uninstall it and install the latest master version.
      Module and full description can be found on github https://github.com/gebeer/FieldtypeImageReference
      Install from URL: https://github.com/gebeer/FieldtypeImageReference/archive/master.zip
      Read on for features and use cases.
      Features
      Images can be loaded from a folder inside site/templates/ or site/assets Images in that folder can be uploaded and deleted from within the inputfield Images can be loaded from other pages defined in the field settings Images can be organized into categories. Child pages of the main 'image source page' serve as categories mages can be loaded from any page on the site From the API side, images can be manipulated like native ProcessWire images (resizing, cropping etc.), even the images from a folder Image thumbnails are loaded into inputfield by ajax on demand Source images on other pages can be edited from within this field. Markup of SVG images can be rendered inline with `echo $image->svgcontent` Image names are fully searchable through the API $pages->find('fieldname.filename=xyz.png'); $pages->find('fieldname.filename%=xy.png'); Accidental image deletion is prevented. When you want to delete an image from one of the pages that hold your site-wide images, the module searches all pages that use that image. If any page contains a reference to the image you are trying to delete, deletion will be prevented. You will get an error message with links to help you edit those pages and remove references there before you can finally delete the image. This field type can be used with marcrura's Settings Factory module to store images on settings pages, which was not possible with other image field types When to use ?
      If you want to let editors choose an image from a set of images that is being used site-wide. Ideal for images that are being re-used across the site (e.g. icons, but not limited to that).
      Other than the native ProcessWire images field, the images here are not stored per page. Only references to images that live on other pages or inside a folder are stored. This has several advantages:
      one central place to organize images when images change, you only have to update them in one place. All references will be updated, too. (Provided the name of the image that has changed stays the same) Installation and setup instructions can be found on github.
      Here's how the input field looks like in the page editor:

      If you like to give it a try, I'm happy to hear your comments or suggestions for improvement. Install from URL: https://github.com/gebeer/FieldtypeImageReference/archive/master.zip
      Eventually this will go in the module directory, too. But it needs some more testing before I submit it. So I'd really appreciate your assistance.
      Thanks to all who contributed their feedback and suggestions which made this module what it is now.
       
    • By rushy
      Hi. I've been using Processwire for a few years now and installed it on a few different shared hosting servers without issues, but I'm now running into an issue on a Fasthosts shared server that I've not seen before. The installation goes ok and I have a working default site profile but I am unable to complete any uploads of images. It just hangs at the progress spinner during the upload. I thought it might be a priviledge issue so have temporarily set the dir / file privs. as 777 / 666 just to test that but it made no difference. I have no errors in the wire log. In server error log I have:
      set_time_limit() has been disabled for security reasons in ....htdocs/wire/core/ImageSizerEngine.php on line 1035 and i note in the assets/file dir. where the image is being stored the date on the file being created has a year of 1970 and 0 length. If I leave the page this file disappears and nothing has been stored. 
      Does anyone know how I can enable set_time_limit if this is likely to be the problem? 
      Many thanks! Paul
×
×
  • Create New...