Hi,

when I change the picture the formatter for an image field to picture I get the following errors when I save the changes to the content type.
Notice: Trying to get property of non-object in picture_field_formatter_settings_summary() (line 389 of /sites/all/modules/picture/picture.module).
Notice: Trying to get property of non-object in picture_field_formatter_settings_summary() (line 391 of /sites/all/modules/picture/picture.module).

Note I have removed the full path reference from the file location.

The installation is Drupal 7.19 with only CTools, Path Auto, Token, Breakpoints and Picture loaded. Have tried with both the picturefill and weblinc options also.

Are there any particular versions of the modules I should be using that I can use.

If you need any more information please let me know.

Kind Regards
Robert

Comments

eguru’s picture

Was using a sub-theme of the Omega them. Change to the default Bartik them and now also get the following errors when displaying a post with the image.

Notice: Trying to get property of non-object in picture_field_formatter_view() (line 437 of /sites/all/modules/picture/picture.module).
Warning: Invalid argument supplied for foreach() in picture_field_formatter_view() (line 437 of /sites/all/modules/picture/picture.module).

Kind Regards
Robert

eguru’s picture

Found the issue.

It seems that settings for the picture field formatter are not correctly saved until you click on the format button to show the options for the field, click the update button, and then click the save button.

After that the picture formatter doesn't cause any errors.

eguru’s picture

Sorry, I should be more specific.

If you change the image formatter to picture and click save you get this error.

If you then click the format options button and click update, then click save the error disappers.

It seems that on the initial save that the picture group information is not saved to the database.

In function picture_field_formatter_settings_summary($field, $instance, $view_mode) the variable $picture_mapping->breakpoint_group is null so the call to breakpoints_breakpoint_group_load returns an array rather than the specific breakpoint associated with the field.

After you click update on field format options and then click save $picture_mapping->breakpoint_group contains the correct picture group name.

Unfortunately I am not skilled enough to trace the source of the problem and create a patch so I hope this helps in solving the problem.

Cheers
Robert

attiks’s picture

You're right, the problem is that we don't know which group we have to select. I'll have a look to see if we can issue a warning so it's clear what you have to do.

eguru’s picture

Just adding to this. The first time, if you change the formatter to picture and view format options it shows a breakpoint group in the picture group. If you then click Update and Save you still get the error.

Am wondering when you click Save the first time whether it could pick up a default value from the picture group if only one exists or display a message asking to select a picture group if more than one breakpoint group exists. If no breakpoint groups exist then it should not allow you to change the formatter to picture.

attiks’s picture

Status: Active » Postponed

@eguru thanks for testing this, but this are problems with drupal core, I think it's a better idea to create bug reports against drupal (8) so it can get fixed for all formatters. If you do so, feel free to post the links in this issue as well so I can track them and hopefully in the future fix it.

carajito’s picture

Assigned: Unassigned » carajito

Hi,

I installed the Breakpoints and Picture module on a test site with Drupal 7.20, Omega and all fine.

Then I installed Breakpoints and Picture on another site with Drupal 7.21, Omega theme and when I Map image styles to picture options I saw the same error

attiks, excellent evolution from resp_img good work

attiks’s picture

#7 Did you get the same errors on the same lines? If so are you using the latest dev version?

aimeerae’s picture

I had this error on Bartik D7.21 and D7.22. Once I upgraded to Picture version = "7.x-1.1+34-dev" and Breakpoints version = "7.x-1.0+4-dev" it went away. Thank you for the great work!

attiks’s picture

Assigned: carajito » Unassigned
Status: Postponed » Closed (works as designed)
steven.wichers’s picture

Status: Closed (works as designed) » Active

This is not fixed. The problem is because the picture_field_formatter_settings_summary() function assumes that it's getting a valid result from picture_mapping_load() regardless of the value of $settings['picture_group']. This means $breakpoint_group = breakpoints_breakpoint_group_load($picture_mapping->breakpoint_group); will always throw PHP notices on servers configured to throw notices after selecting the picture formatter. The solution is to actually check that the return values contain the properties that are being read.

indigoxela’s picture

Hi,
steven is right, the problem still exists.

Here is a related issue: https://drupal.org/node/2113217

According to that issue, the problem should be fixed since Version 7.x-1.2, but it isn't.
(See also: http://drupalcode.org/project/picture.git/shortlog/refs/tags/7.x-1.2)

So I'm setting this issue back to active.
Unfortunately version 7.x-1.2 is not functional, because a picture field formatter can never get saved.

indigoxela’s picture

Version: 7.x-1.x-dev » 7.x-1.2
Issue summary: View changes
indigoxela’s picture

Status: Active » Closed (works as designed)

Sorry, module version 7.x-1.2 works as it should. My fault, I forgot to map picture to the correct breakpoint group. After adding the correct group, it became visible in field settings and the formatter could be saved without errors.

Kojo Unsui’s picture

Status: Closed (works as designed) » Active

Config : Drupal 7.24, Theme Zen 7.x-5.4
With version 7.x-1.2, breakpoint group and image styles mapped in Picture configuration, I've still got the error Trying to get property of non-object in picture_field_formatter_settings_summary() (line 455...

So I can't select the Picture formatter in content type/ manage display nor access its format settings.

Any help is welcome...

Kojo Unsui’s picture

I turned around the problem by disabling errors display.

But I confirm that Notice: Trying to get property of non-object in picture_field_formatter_settings_summary() still appear while changing the display setting from image to picture.

Bikkne’s picture

*sorry saw that it was another formatter() created a new issue for 2.0 vesion*

I made a clean install of Picture 2.0 and still get this? error:
"Notice: Trying to get property of non-object in theme_picture_formatter() (line 456 of /srv/www/htdocs/drupal/sites/all/modules/contrib/picture/picture.module)."
Using PHP Version 5.4.20
I use the Picture field in a Panel Pane through Panels & Omega 4

The module and everything else seems to work fine, though the notice comes up in the "modal form" webform for anonymous users so I suppressed the error notice with adding an @ sign in front of the line in 456 and it all seems fine:
@$responsive_image['#title'] = $item->title;

Are there any know issues doing it this way?

Mneznakomec’s picture

line 456 in picture/picture.module:
insteed
$responsive_image['#title'] = $item->title;
use
$responsive_image['#title'] = $item['title'];

It work for me: title for image created and no errors.

attiks’s picture

Version: 7.x-1.2 » 7.x-1.x-dev
Status: Active » Fixed

Fixed in 2.0, should be fixed in 1.3

  • Commit f318873 on 7.x-2.x by attiks:
    Issue #1903928 by eguru: Fixed Errors when saving content type using...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.