i'm sorry if i'm missing something but i guess that Views is lacking a field in the audio node type: the audio node image. the item in drupal database is called audio_image. Is Views supposed to recognize it automatically once it's installed? If so, Views is not doing that in my installation.
or is there any way it can be added?
thank you very much

CommentFileSizeAuthor
#11 views_audio.zip1.93 KBcostinius

Comments

merlinofchaos’s picture

Status: Active » Closed (works as designed)

Views supports core fields by default; audio_image is provided by a module; I"m not even sure what module that is, since I don't think that's audio.module unless it's been added relatively recently. In any event, module's fields must be exposed to views by that module. Either the module in question isn't, or perhaps it isn't correct.

drewish’s picture

Title: views misses the audio_image field » Add views support for images.
Project: Views (for Drupal 7) » Audio
Component: Code » audio_image
Category: bug » feature
Status: Closed (works as designed) » Active

Rather than opening my own issue, i'll just move this to the audio module queue.

drewish’s picture

Version: 4.7.x-1.x-dev » 5.x-1.x-dev
Component: audio_image » Views support
drewish’s picture

Version: 5.x-1.x-dev » 5.x-2.x-dev

i do want to work on this. it should be pretty simple.

mike.hobo’s picture

This is what i was looking for, I went into the views_audio.inc file and tried to add this code

  $tables['audio_image'] = array(
    'name' => 'audio_image',
    'join' => array(
      'left' => array(
        'table' => 'audio',
        'field' => 'vid'
      ),
      'right' => array(
        'field' => 'vid'
      )
    ),
     'fields' => array(
       'value' => array(
         'audio_images' => array(
            'name' => t('Audio: Album Image'),
             'notafield' => TRUE,
             'sortable' => FALSE,
             'help' => t('This will display the image of the audio node.')),
        ),
      ),
    )

But.. I guess this is not how the views works... After doing this, i looked in the views and their was no field for "Audio: Image"

I have also tried to go into the SQL and go to the view_tablefield and add an audio_image row into there.

I am very unexperienced in all of this.. but I will look into how "User: Author Picture" works.

mike.hobo’s picture

I really want this feature.. So if anyone knows alot about views. I added this to views_audio.inc

  $table['audio_image'] = array(
    'name' => 'audio_image',
    'join' => array(
      'left' => array(
        'table' => 'audio_image',
        'field' => 'vid'
      ),
      'right' => array(
        'field' => 'vid'
      )
    ),
    'fields' => array(
      'audio_image' => array(
        'name' => t('Audio: Image'),
        'handler' => 'views_handler_field_audio_images',
        'notafield' => TRUE,
        'sortable' => FALSE,
        'help' => t("This will display the audio file's size."),
      ),
    ),
  );

And this is the handler I added.

function views_handler_field_audio_images($audio_images, $url) {

  if ($image = audio_images_get($audio_images)) {


    return "<div class='audio-image'>\n <a href=".url('node/'. $url).">". theme('audio_image', $image) ." </a>\n</div>\n";

  }

}

Is there anyway this can be altered to work correctly?

costinius’s picture

Hi, I think I found the solution. I've created this code below quite fast and didn't test it well enough. But it works for me (except for the image theming, but I think this can be solved).

Step 1. Put the following code in the views_audio.inc under the $tables['audio'] // 'fields' => array(:

	'audio_images' => array(
        'name' => t('Audio: Audio image'),
        'handler' => 'audio_views_handler_field_image',
        'notafield' => TRUE,
        'sortable' => FALSE,
        'help' => t('This will display an audio image.'),
      ),

Step 2. Create a handler function below:

function audio_views_handler_field_image($fieldinfo, $fielddata, $value, $data) {
  $node = node_load($data->nid);
  if ($node->audio_images) {
    return theme('audio_images', $node->audio_images);
  }
}

If you can bring this code further so that it will theme the image as needed, please share. Hope it helps.

drewish’s picture

i think the approach in #6 is the correct one, it would allow you to include info on the image's size and type.

mimancillas’s picture

I tried both #6 and #7 but had no luck with either. This would be a cool tool. I guess I'll follow mike.hobo's lead and research "User: Author Picture" and try and figure it out.

mike.hobo’s picture

yah. my code was incorrect, i was just jotting stuff. my solution to this was to give up and use imagefield. But this doesn't really help if you are trying to have the audio_feeds module's xspf feeds to have images.

costinius’s picture

StatusFileSize
new1.93 KB

Hi, I'm not sure why #7 didn't work for you, just some stupid thing to bear in mind. At first when I created the code I also though it didn't work. Then it turned out that I just didn't notice the new field "Audio: Audio image" in the views field chooser. The problem is the views field chooser doesn't sort the fields alphabetically - the fields are sorted the way you put them in the module code.

Anyway, I attach the file "views_audio.inc" that works for me. Just in case.

PS: I'm using Audio module 5.x-1.3, Views 5.x-1.6

CinemaSaville’s picture

Can this be included for Drupal 6? Thanks.

drewish’s picture

Version: 5.x-2.x-dev » 6.x-1.x-dev

yeah probably won't do anything with it in 5.x

CinemaSaville’s picture

So you will include this? I'm not sure what the response meant.