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
(
)
)
)
Comments
Comment #1
rooby commentedHere is a debug_backtrace() from the point of the error.
Comment #2
rooby commentedSorry, Using:
drupal 7.2
media 7.x-1.x-dev
styles 7.x-2.x-dev
Comment #3
kreynen commentedsubscribe
Comment #4
RobW commentedSame error here, subscribing.
Comment #5
yareckon commentedalso 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.
Comment #6
yareckon commentedI 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.
Comment #7
rooby commentedWell, 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.
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).
Comment #8
RobW commentedThe 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.
Comment #9
glass.dimly commented+1
Comment #10
dave reidThis resolved the problem for me locally with Media fields.
Comment #11
rooby commentedThanks for the patch, it works for me for my testing.
Comment #12
mightyiam commentedThis patch did the trick for me, also. Thanks!!!
Comment #13
stephen Piscura commentedHey team,
I just updated to Media 7.x-1.0-beta5 and i'm getting the following error:
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...
Comment #14
dddave commentedI 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.
Comment #15
Carlos Miranda Levy commentedI confirm that applying patch manually against alpha8 and it seems to work.
Comment #16
aaron commentedgot it, thanks for the catch!
Comment #17
jmones commentedThx, worked as advertised for me too.
Comment #18
tr33m4n commentedpatch in #10 worked, however would love this to work for Media: Youtube as well
EDIT: woops http://drupal.org/node/1203252
Comment #19
Ravi.J commented#10 works perfectly, Marking RTBC
Comment #20
Scatterspell commentedSince I'm a git moron I had to manually patch it, but works perfectly.
Comment #21
zhangyb commentedconfirm that #10 works for me too.
Comment #22
arnoudt commentedComment #23
arnoudt commentedComment #24
phoenix commentedGot the same problem here. The patch solved my problems.
Thanks Dave !
Comment #25
BeaPower commentedI 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).
Comment #26
dave reid@BeaPower: Likely a similar fix has to be made against media_youtube. File a new issue under that module.
Comment #27
rickvug commentedSubscribe.
Comment #28
luksakdidn't fix for me.
Comment #30
jwilson3Instead 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?
Comment #31
jwilson3For example...
(this fixes the issues reported in #25)
Comment #32
nedjoPatch in #31 resolved the remaining error but didn't apply:
Comment #33
jwilson3@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
Comment #34
aaron commentedthanks @jwilson3, committed #31.
Comment #35
jwilson3thanks @aaron!
Comment #36
lsolesen commented+1
Comment #38
damien_vancouver commentedSorry 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!!
Comment #39
nicknickoli commentedsubscribe
Comment #40
jjclint commentedI'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?
Comment #41
jjclint commentedThought 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?
Comment #42
blenny commentedI have this error when using styles with Media module
Comment #43
Oleksandr.Masovets commentedHi 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.
Comment #44
jwilson3The patch in #43 *looks* good, but I havent had time to test the code.
Comment #45
jwilson3Comment #46
ThaiGringo commentedsubscribe (patch works for me, too.)
Comment #47
michaeldhart commentedDitto- I was having issued with Media Youtube as well as the Undefined property error. Patch #43 seems to resolve.
Comment #48
penguininja commentedThe patch in #43 works for me with Drupal 7.12, Styles 7.x-2.0-alpha8, and Media 7.x-1.0-rc3. Thanks!
Comment #49
geek-merlincrosslinking: there is another patch at #797502: Needs Tests: File Styles applied to file fields in any entity other than media leads to warnings and lack of display
Comment #50
sierraoscardelta commentedSo far so good with #43 patch. Many thanks Krasnyj.
Comment #51
HappyJiyoung commentedNewbie here...

Can someone kindly tell me how to apply patch?
After I did this, command line is asking...like this.
Thank you!
Comment #52
rooby commented@HappyJiyoung:
patch -p1 < styles.module-1186624.patchComment #53
HappyJiyoung commentedThank you!! :)))))
Comment #54
nedjoRestoring previous status.
Comment #55
jeni_dc commentedI 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.
Comment #56
esmerel commentedAlso working for me! :)
Comment #57
bluegeek9 commentedThank you for your contributions to this issue. As Drupal 7 has reached its End of Life and is no longer supported, we are closing this issue. We encourage you to upgrade to a supported version of Drupal.