I am getting these errors when viewing a node that has a multimedia asset field on it for images, using a media style for display.

Notice: Undefined property: stdClass::$uri in file_styles_styles_filter() (line 40 of /var/www/mysite/sites/all/modules/styles/contrib/file_styles/file_styles.module).
Notice: Undefined property: stdClass::$filemime in file_styles_styles_filter() (line 56 of /var/www/mysite/sites/all/modules/styles/contrib/file_styles/file_styles.module).

If I insert if I insert the images into the body using WYSIWYG everything works as expected but when using the field I get the errors and the image doesn't display.

The object in question is:

                    [0] => stdClass Object
                        (
                            [fid] => 5
                            [title] => 
                            [data] => 
                            [file] => stdClass Object
                                (
                                    [fid] => 5
                                    [uid] => 1
                                    [filename] => IMG_5056.jpg
                                    [uri] => public://IMG_5056.jpg
                                    [filemime] => image/jpeg
                                    [filesize] => 1697491
                                    [status] => 1
                                    [timestamp] => 1307929907
                                    [type] => image
                                    [field_caption] => Array
                                        (
                                        )

                                )

                        )
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

rooby’s picture

Here is a debug_backtrace() from the point of the error.

rooby’s picture

Sorry, Using:
drupal 7.2
media 7.x-1.x-dev
styles 7.x-2.x-dev

kreynen’s picture

subscribe

RobW’s picture

Same error here, subscribing.

yareckon’s picture

also hitting this. Looks like there is a wrapper here (maybe from media module) that styles is not taking account of. It wants to grab the inner file object rather than that media wrapper object.

yareckon’s picture

I have this error when using styles module in combination with a very dev version of the media module and display suite.

The easiest way to work around this incompatibility is under the display management for your content type, you need to switch from using the "Media style:my format name" format styles to using the basic "Media" format, and then setting up file view modes will then show up on the right. You can then select these, and the errors go away.

I'm not sure how this workaround effects non image content, so if you are working with video for instance, do make a backup of your database before messing around with the settings as suggested above.

rooby’s picture

Well, you can discount display suite as a contributing factor as I have the same problem and don't have display suite installed.
I know very little about the workings of these modules at this stage but I'd say it is either a problem with either Media or Styles.

The easiest way to work around this incompatibility is under the display management for your content type, you need to switch from using the "Media style:my format name" format styles to using the basic "Media" format...

I have been using the same work around and can confirm that it works this way (at least for images, not sure about other types).

RobW’s picture

The workaround is indeed a workaround, though -- media module maintainers have stated that the correct way of applying formatters to media fields on a per field basis is through the "media style: style XXX". In fact, you can use the workaround without styles installed at all since that particular functionality is provided by media module.

glass.dimly’s picture

+1

Dave Reid’s picture

Status: Active » Needs review
FileSize
2 KB

This resolved the problem for me locally with Media fields.

rooby’s picture

Thanks for the patch, it works for me for my testing.

mightyiam’s picture

This patch did the trick for me, also. Thanks!!!

stephen Piscura’s picture

Version: 7.x-2.x-dev » 7.x-2.0-alpha8

Hey team,

I just updated to Media 7.x-1.0-beta5 and i'm getting the following error:

  • Notice: Undefined property: stdClass::$uri in file_styles_styles_filter() (line 33 of .../sites/all/modules/styles/contrib/file_styles/file_styles.module).
  • Notice: Undefined property: stdClass::$filemime in file_styles_styles_filter() (line 49 of .../sites/all/modules/styles/contrib/file_styles/file_styles.module).

I'm wondering whether or not to apply Dave's patch, given that i'm running a new version of media AND i'm running Styles 7.x-2.0-alpha8—not dev...

I think i'm just going to go ahead and do it anyway. I'll let you know if i create a worse mess for myself...

dddave’s picture

I applied this patch by hand against alpha8 and it kills the notices. Guess a slight reroll is needed but basically the patch works as advertised.

Carlos Miranda Levy’s picture

I confirm that applying patch manually against alpha8 and it seems to work.

aaron’s picture

Status: Needs review » Fixed

got it, thanks for the catch!

jmones’s picture

Thx, worked as advertised for me too.

tr33m4n’s picture

patch in #10 worked, however would love this to work for Media: Youtube as well

EDIT: woops http://drupal.org/node/1203252

Ravi.J’s picture

#10 works perfectly, Marking RTBC

Scatterspell’s picture

Since I'm a git moron I had to manually patch it, but works perfectly.

zhangyb’s picture

confirm that #10 works for me too.

arnoudt’s picture

arnoudt’s picture

phoenix’s picture

Got the same problem here. The patch solved my problems.
Thanks Dave !

BeaPower’s picture

I applied patch #10 but get new error:

Notice: Undefined property: stdClass::$uri in media_youtube_file_styles_filter() (line 65 of C:\xampp\htdocs\jorga\sites\all\modules\media_youtube\includes\media_youtube.styles.inc).

Dave Reid’s picture

@BeaPower: Likely a similar fix has to be made against media_youtube. File a new issue under that module.

rickvug’s picture

Subscribe.

Lukas von Blarer’s picture

didn't fix for me.

Status: Fixed » Closed (fixed)

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

jwilson3’s picture

Instead of fixing this in other modules, it seems this module is actually breaking its own API (which is still apparently unwritten, unless I'm missing something), as the "$object" expected in hook_file_styles_filter by the media_youtube, media_flickr, and media_vimeo all seem to expect a $file object, not this wrapper $object mysteriously introduced by the latest media module changes.

Can we not just fix this once, here in this module and pay it forward for the others that implement the hook?

jwilson3’s picture

Version: 7.x-2.0-alpha8 » 7.x-2.x-dev
Status: Closed (fixed) » Needs review
FileSize
1.8 KB

For example...

(this fixes the issues reported in #25)

nedjo’s picture

Patch in #31 resolved the remaining error but didn't apply:

$ git apply -v styles-hook_file_styles_filter-1186624.patch
error: www/sites/all/modules/contrib/styles/contrib/file_styles/file_styles.module: No such file or directory
jwilson3’s picture

@nedjo:

cd /path/to/modules/styles/contrib/file_styles

wget http://drupal.org/files/issues/styles-hook_file_styles_filter-1186624.patch

patch < styles-hook_file_styles_filter-1186624.patch

aaron’s picture

Status: Needs review » Fixed

thanks @jwilson3, committed #31.

jwilson3’s picture

thanks @aaron!

lsolesen’s picture

+1

Status: Fixed » Closed (fixed)

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

damien_vancouver’s picture

Sorry to spam everyone on this thread, but...

I encountered the above error trying to use media_youtube. Upgrading from 7.x-2.0-alpha8 to 7.x-2.x-dev fixed my problem.

I see that it's been a few months and I'm not the first one... is there any chance we could see a new recommended release of styles (ie. a 7.x-2.0-alpha9) made from the current 7.x-2.x-dev?

That would prevent other people from encountering this problem in the wild, which does seem to be happening (see : http://drupal.org/node/1203252#comment-4998430 and below).

And of course, thank you for all your hard work!!

nicknickoli’s picture

subscribe

jjclint’s picture

I'm using the latest 7.x-2.x-dev from 2011-sep-12 and I also get these errors, so I don't think it can be tagged as fixed.
I'm trying to apply the patch from #10 but I get these errors:

Checking patch contrib/file_styles/file_styles.module...
error: contrib/file_styles/file_styles.module: No such file or directory
Checking patch contrib/file_styles/includes/styles/FileStyles.inc...
error: contrib/file_styles/includes/styles/FileStyles.inc: No such file or directory

Am I not in the right folder?

Why this patch isn't being committed it's been a while now?

jjclint’s picture

Thought it's also worth mentioning the errors I get for the media and style modules:

Notice: Undefined index: 74 in mediafield_field_prepare_view() (line 159 of /home/public_html/sites/all/modules/media/modules/mediafield/mediafield.module).
Notice: Undefined property: stdClass::$uri in file_styles_styles_filter() (line 44 of /home/public_html/sites/all/modules/styles/contrib/file_styles/file_styles.module).

As I said I'm using the latest styles 7.x-2.x-dev with the latest media 7.x-2.x-dev and Media: YouTube
7.x-1.0-alpha5.

EDIT: I've tried to update media: youtube to the latest dev version but I get the exact same errors. When I don't use file styles to yield an image style all errors disappear. Looking back at the errors posted by the starter of the thread I'm not even sure I have the same problem anymore.
Any advice?

blenny’s picture

Status: Closed (fixed) » Active

I have this error when using styles with Media module

Oleksandr.Masovets’s picture

FileSize
959 bytes

Hi all.

We need to fix the source of the problem instead of fixing the 'symptoms'.
Here is the patch which fixes the issue (7.x-2.0-alpha8, 7.x-2.0-dev) and Media module (and Media sub-modules) works fine with it. Patches #10 and #31 are not needed in this case. Please, check it.

jwilson3’s picture

The patch in #43 *looks* good, but I havent had time to test the code.

jwilson3’s picture

Status: Active » Needs review
ThaiGringo’s picture

subscribe (patch works for me, too.)

michaeldhart’s picture

Ditto- I was having issued with Media Youtube as well as the Undefined property error. Patch #43 seems to resolve.

penguininja’s picture

The patch in #43 works for me with Drupal 7.12, Styles 7.x-2.0-alpha8, and Media 7.x-1.0-rc3. Thanks!

geek-merlin’s picture

sierraoscardelta’s picture

So far so good with #43 patch. Many thanks Krasnyj.

HappyJiyoung’s picture

FileSize
10 KB

Newbie here...
Can someone kindly tell me how to apply patch?
After I did this, command line is asking...like this.
Only local images are allowed.

Thank you!

rooby’s picture

@HappyJiyoung:
patch -p1 < styles.module-1186624.patch

HappyJiyoung’s picture

Assigned: Unassigned » HappyJiyoung
Status: Needs review » Reviewed & tested by the community

Thank you!! :)))))

nedjo’s picture

Status: Reviewed & tested by the community » Needs review

Restoring previous status.

jeni_dc’s picture

I can confirm the patch is working well for me as well with Styles 7.x-2.0-alpha8 and Media 7.x-2.0-unstable6+3-dev.

esmerel’s picture

Also working for me! :)