Jump to content
hettiger

$image->description returns an empty string for guest users

Recommended Posts

Hello there.

Since this is my first post in these forums: Thank you Ryan for ProcessWire and thanks to everyone that is supporting him or other users.

I'm having a strange problem using $image->description. When I'm logged in as the default user I registered during install everything's working as expected. $image->description returns the string provided in the backend. Anyways if not logged in, an empty string will be returned resulting in <img src="url-is-still-working" alt="">.

I don't really know whats going on. Might be a bug? Here's some code:

$slides = '';

foreach ( $page->slideshow_images as $image )
{
    $slides .= '<li><img src="' . $image->url . '" alt="' . $image->description . '"></li>';
}

I'm running ProcessWire 2.5.3.

Share this post


Link to post
Share on other sites

Hi hettiger,

Welcome to ProcessWire! :)

Do you have template cache enabled or using MarkupCache by any chance?

If it's a multilang site: Does the guest user maybe have a language where the image description isn't filled/translated?

Cheers

  • Like 2

Share this post


Link to post
Share on other sites

Hi hettiger,

Welcome to ProcessWire! :)

Do you have template cache enabled or using MarkupCache by any chance?

If it's a multilang site: Does the guest user maybe have a language where the image description isn't filled/translated?

Cheers

Thank you Wanze,

with your help I was able to fix this issue.

I disabled multilingual descriptions on this image field. (The site itself is not multilingual, but the backend is)

Share this post


Link to post
Share on other sites

Hi,

I have a similar problem: I upgraded a website to the latest PW version (currently 2.5.3) and the image description stopped working all of a sudden. It's also a multi-language site, and same as above, only for the backend: the front-end is in german. I checked the database and noticed that the old descriptions are strings, and the new ones arrays. 

Is there a way to have them be strings again? The "Disable multi-language descriptions" function didn't quite do the trick so far, except that it hid the multi-language field in the backend, which is in my case an improvement already.

Any suggestions?

Thanks!

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 picarica
      so this is really weird issue i am so confused about this, so i have setup 'images' field where i put images and the include them in CKeditor, should work right? well it works on some sites, i use it nearly in every page but at one page, the images included in that CKeditor only show up, when i am logged into processwire, when i turn on incognito mode the images dissapear, but only on this specific page, everywhere else it works perfectly, has anyone came across this issue? i have nowhere in the site login checker, i have no idea what is going on
    • By picarica
      so i am trying to fetch dimensions of image using getimagesize() but it returns nothing, at least i think so, i want to feed it to data attribute, bit its emtpy, i tried feeding it the image directly or just image->url
      here is my source code

       
      foreach($page->repeat_body as $r_body) { /* other code here*/ if ($r_body->gallery_check == 1) { echo "<div class='my-gallery' id='grid-gallery' itemscope itemtype='http://schema.org/ImageGallery'>"; foreach($r_body->image as $image) { $options = array('quality' => 80, 'upscaling' => true, 'cropping' => 'north', 'sharpening'=>'medium'); $thumb = $image->size(400, 400, $options); $large = $image->size(1280, 0, $options); list($width, $height) = getimagesize($image->url); echo " <figure itemprop='associatedMedia' itemscope itemtype='http://schema.org/ImageObject'> <a href='$large->url' itemprop='contentUrl' data-size='$widthx$height' data-index='0'> <img src='$thumb->url' height='$height' width='$width' itemprop='thumbnail' alt='Beach'> </a> </figure>"; } echo "</div>"; } /* other code here*/ } now, the images are outputted correctly, i can open then and browse them
    • By olafgleba
      Hi,
      maybe kind of related to https://processwire.com/talk/topic/13286-image-description-not-saving/ but with other environment bits.
      While adding a new page/edit a existing page containing a image field, the image itself gets stored into the database but strangely the entered description does not. More strangely this only happens on my staging server. Within my local dev environment all is fine. And beside of this particular problem, all parts of the PW instance works fine. On both environments (s. below).
      First suspicion was the varying PHP/mysl versions of the local <-> staging environment. But, there are many working projects with the identical setting (s. below).  And i never encounter this problem so far.
      No error/log/console output. It just fails to get stored.
      Local Environment: PHP  7.4.6, mysql 5.7.29, PW 3.0.148
      Staging Environment*: PHP 7.0.33, maria DB 10.1.46, PW 3.0.148
      Maybe someone has a hint what to try?  Thanks in advance.
      *) I cannot change the staging server php/mysql settings because its part of a shared hosting account.
    • By DanielKit
      Hi. I'm currently stuck at the login page in my project. Once I enter my admin username and my password and press login, nothing happens. The page just reloads. However, the URL changes from http://myipaddress/processwire to http://myipaddress/processwire/?login=1. I've checked all of my server settings, and to my knowledge, all seems to be fine there. I don't know where to go from here.. Thanks in advance!
    • By modifiedcontent
      Small annoyance: I get a horizontal scrollbar in UIkit admin area - or actually Admin Theme Boss based on Uikit 3. I tried to fix it with CSS, but had trouble isolating/targeting it and don't want to mess with module or core files. I think this issue has been reported before. Is there a recommended fix? 
×
×
  • Create New...