Skip Navigation

[Geschlossen] View showing a site attachments list filtered by post_mime_type?

This support ticket is created vor 7 Jahre, 6 Monate. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 3 Antworten, has 2 Stimmen.

Last updated by Minesh vor 7 Jahre, 6 Monate.

Assigned support staff: Minesh.

Author
Artikel
#320797

I'm trying to create a 3 columns view which shows images in the first column, pdf's in the second one and finally audio/video.

I guess i need to use the post_mime_type filter but i don't know if it's the best way or if i'm doing it right. Should i use the [Wpv-if] shortcode?

How should i type the wpv-if shortcode in that case?

Thanks in advance

#320836

Minesh
Supporter

Languages: Englisch (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello and thank you for contacting Toolset support.

1)
As I understand you want to list three different type of media in different columns but it should remain same in single column while its looping in views.

You can use wpv-if to check your custom field values. You can find more details on that on following link:
=> https://toolset.com/documentation/user-guides/conditional-html-output-in-views/

--- Please share a link where I can see your issue in action explaining your issue.
--- Few screenshots will be helpful.

2)
Could you please send me debug information that will help us to investigate your issue.
=> https://toolset.com/faq/provide-debug-information-faster-support/

#321183
wptypes.jpg

Hello Minesh, thanks to you for the fast reply.

1) I attached a sketch of what i'm trying to do (it would be 3 columns, so maybe it would be better to make 3 differetnt views, one for each format Images/pdf/audio-video)

I tried a WPV-if but i think i didnt syntaxed it propperly.

How should i check if post_mime_type is an image or pdf?

[wpv-if post_mime_type="image/jpg" evaluate="$post_mime_type = 1'"] (here display the images thumbnail) [/wpv-if] ??

--- Please share a link where I can see your issue in action explaining your issue.
--- Few screenshots will be helpful.

2) it's not actually a bug problem, is more that i have doubts about how to program the functionality with Toolset.

Really thanks for your help!

#321206

Minesh
Supporter

Languages: Englisch (English )

Timezone: Asia/Kolkata (GMT+05:30)

1)
I think you should use some custom shortcode which will return you the string based on the post_mime_type and then you should check the returned string that returned based on the "post_mime_type".

-- But here you need to fetch attachment ID based on the post ID.
More references:
=> https://codex.wordpress.org/Function_Reference/get_post_mime_type

add_shortcode('get_mime_type',get_mime_type_for_attachment);
function get_mime_type_for_attachment($id) {

  $type = get_post_mime_type($id);
  switch ($type) {
    case 'application/pdf':
       return 'PDF'; 
       break;
    case 'image/jpeg':
    case 'image/png':
    case 'image/gif':
      return 'IMAGE'; 
       break;
    case 'video/mpeg':
    case 'video/mp4': 
    case 'video/quicktime':
      return 'AUDIO'; 
      break;
    case 'text/csv':
    case 'text/plain': 
    case 'text/xml':
      return 'TEXT'; 
       break;
     }
}

More references:
=> https://wordpress.org/support/topic/how-to-retrive-mime-type-for-the-current-get-attachment
=> http://stackoverflow.com/questions/5767050/how-to-retrieve-mime-type-for-the-current-get-attachment

But here I would like to know the structure that with which post type you are dealing with, is this attachment?

2)
In order to be of better help, it will be great if you provide me test install where I can see your data structure, views, post_types etc..etc and I will help you further with shortcode.

*** Please take FULL BACKUP of your database and your website.***
In order to investigate your issue if we require to check things on your install in order to see what could be going wrong there.

If you agree to this please use the form fields I have enabled below this comment box to provide temporary access details (wp-admin and FTP)?

I have set next reply as private.

Das Thema „[Geschlossen] View showing a site attachments list filtered by post_mime_type?“ ist für neue Antworten geschlossen.