I'm not sure with which module this problem lies but, when I have a view with a rendered file field and use media_preview as the view mode it shoudl be using the media_formatter_large_icon display.

Whenever I try to use this media_formatter_large_icon display I get the following message:

Notice: Trying to get property of non-object in file_icon_path() (line 808 of /var/www/mysite/modules/file/file.module).

It is because theme_media_formatter_large_icon is being called without a file object but I don't know why that is.

Comments

rooby’s picture

I am doing this with audio and video file types if it matters.

amfriedman’s picture

+1

dave reid’s picture

Status: Active » Postponed (maintainer needs more info)

I'm unable to reproduce this but I see it occasionally. The best thing is to add a dpm(debug_backtrace()) to file_icon_path() to help debug where the issue is coming from and what function calls are in the tree causing the error.

damienmckenna’s picture

In my situation it stems from using a video field using Media v2 and generated content.

drzraf’s picture

dave reid’s picture

Still have been unable to reproduce this error. I think we might need more detailed, exact steps to reproduce otherwise I'll have to close this issue.

oystercrackher’s picture

I am getting the same error: Notice: Trying to get property of non-object in file_icon_path() (line 809 of C:\Melissa\Drupal\Installation\Versions\Drupal Core\drupal-7.x\modules\file\file.module).

My steps were as follows:

I have created MiniPanel with Photos in one panel on the left and Videos in another pane on the right. I have selected "media" as the formatter and have selected "preview" as the view mode". When viewing the page, I get the error listed above; this error only exists for the preview view mode. I hope this helps.

This happens if I use my own content or devel generated content.

Please let me know if you need anything else.

Thanks

oystercrackher’s picture

OK! I was able to resolve this issue for photos by doing the following:

Under structure/file types on the manage file display tab, select preview mode, ensure that image is selected for enabled displays, then for view modes for the image, select thumbnail (apparently square thumbnail was originally set); then save. Issue resolved for photos in preview mode.

This does not solve the issue for videos in the preview mode however; can someone please advise what display is being used for videos and how it may be fixed. Would like to ensure that can see small still image which then links to content when selected.

Thanks

esmerel’s picture

I get this error on lines 809, 852, and 824 (probably a dozen messages total)

I only see this when I attempt to use the 'preview' file view mode for the media field in a view. The preview comes up, but there's those errors. If I use any other file view mode, they don't show any images, but they also don't spit errors.

I'm currently using 7.x-2.0-unstable5+4-dev. There's nothing in the error log. Sadly, oystercrackher's suggestion did not work for me.

esmerel’s picture

Status: Postponed (maintainer needs more info) » Active
StatusFileSize
new1.15 KB

OK, I have done the backtrace and merlinofchaos says that media_formatter_large_icon is being called without a file.

I've attached the tiny bit that merlin thought was important, but I can give access later.

dave reid’s picture

Assigned: Unassigned » dave reid

I think I'm able to replicate this having a local video file entity being run through file_view($file, 'media_preview') using the defaults of Media module. I'm looking into this now to debug further.

robertinop’s picture

I am getting the same errors as #9, with Media 7.x-2.0-unstable6+3-dev (2012-Jul-26) and Media: YouTube 7.x-2.0-alpha2+2-dev (2012-Jul-24). This is after updating from the recommended version of Media:YouTube, 7.x-2.0-alpha2 (2012-Apr-24). Also as with #9, this happens when displaying a view block of videos using Preview view mode, and not with other view modes. I'm using Views 7.x-3.3.

Maybe this will help narrow down the problem?

drzraf’s picture

see also the stacktrace posted in #1139980: Undefined index: file_icon_path

dave reid’s picture

I have already posted I've been able to track what's going wrong. I'll be debugging and attempting to fix this weekend.

Kazanir’s picture

This appears to work fine in the Views Preview when setting up the view, but then throws all of these errors when looking at the live page. It seems to clearly be a problem with the Large File Icon or Generic File rendering option:

- The reason many people are seeing it is because "Rendered file" seems to default to Generic File if no rendering types are picked for the particular display type. (In my case, I had forgotten to set up the Preview display type for several kinds of file.)

- Once I set up the Preview display type and put "URL to file" underneath the the LFI/GF options, that put a floor under the display possibilities and prevented the error from showing up. I assume the error is still occurring which is why the Generic File rendering is failing to show up and I get the link instead.

- Strangely, the GF option DOES seem to work as part of the standard Media Browser format for Views. I only observe this error when switching to a Grid format and displaying the File or Rendered Entity, or when displaying Fields with Rendered File as one of the fields.

esmerel’s picture

I'd concur with previous poster - I changed the formatter to 'small' instead of preview and all the errors went away.

damienmckenna’s picture

Could it be that 'preview' did had an incomplete display configuration, e.g. an image style wasn't defined, etc?

esmerel’s picture

I created a 'preview' image style. It seems that the errors aren't happening now. I'm not sure that's the 'correct' behavior, since there's file view modes available that aren't listed as image styles. Maybe I'm mixing the terms up?

esmerel’s picture

bah, spoke too soon. Still happening.

eusonic’s picture

Dave,

Any update on this bug?

Thanks
-Cameron

esmerel’s picture

I wouldn't expect any updates from Dave for a few weeks at least. https://twitter.com/davereid/status/257995930236760064

damienmckenna’s picture

Maybe someone could request this to be worked on during next week's code sprint? #1817164: Brainstorming & priorities planning for the Drupalcamp Atlanta 2012 Code Sprint

agentrickard’s picture

Assigned: dave reid » agentrickard

Taking a sprint look.

agentrickard’s picture

Cannot replicate. An export of settings for the View and the File Type would be immensely helpful.

agentrickard’s picture

Assigned: agentrickard » Unassigned
esmerel’s picture

StatusFileSize
new43.68 KB

Here you go.

esmerel’s picture

I can also provide access to a site where this is replicatable :) Dave had already done so, but things got in the way. :D

agentrickard’s picture

Got it, thanks.

agentrickard’s picture

Actually, the error I get is:

Notice: Trying to get property of non-object in views_handler_field_comment_link->render_link() (line 53 of /Applications/MAMP/htdocs/drupal-7-workbench/sites/all/modules/views/modules/comment/views_handler_field_comment_link.inc).

But i haven't loaded any video files in yet.

agentrickard’s picture

StatusFileSize
new173.16 KB

OK, getting both errors now.

esmerel’s picture

The views error is a known issue #1816960: Trying to get property of non-object in views_handler_field_comment_link->render_link() (line 52 of views_handler_field_comment - I have a hack fix in on my site, but merlinofchaos wants to fix it properly when he gets a chance. I didn't think to mention it, sorry!

agentrickard’s picture

Project: D7 Media » File Entity (fieldable files)
Component: File entity » Code
StatusFileSize
new634 bytes

As far as I can tell template_preprocess_file_entity() never attaches the $file to $variables['content'] during the render process.

This patch addresses that issue.

agentrickard’s picture

Yeah, that Views bug is unrelated to this issue. I just removed the comment fields.

Patch seems to work. Note, however, that it actually changes the render style of the large file icon.

agentrickard’s picture

Status: Active » Needs review
esmerel’s picture

Patched this manually against 7.x-2.0-unstable6 and the error is gone, hooray!

ParisLiakos’s picture

Status: Needs review » Fixed

applied the patch and tested, this doesnt changes large filetype icon for me:/

Thanks agentrickard!
patch commited
http://drupalcode.org/project/file_entity.git/commit/30d1f66

agentrickard’s picture

StatusFileSize
new17.65 KB
new17.21 KB

Here's the change for me, using @esmerel's view.

Before

After

ParisLiakos’s picture

seems that the after is the correct one:) the fitst one is for document:/

Status: Fixed » Closed (fixed)

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