Skip Navigation

[Resolved] Image field to show only images uploaded to a post, not all in media library

This support ticket is created 5 years, 7 months ago. 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Karachi (GMT+05:00)

This topic contains 2 replies, has 2 voices.

Last updated by barryG-4 5 years, 7 months ago.

Assisted by: Waqar.

Author
Posts
#1227806

Tell us what you are trying to do?
When a user clicks 'Add New' in an image field inside a CPT post, is it possible to view only images previously uploaded to that CPT post and not all images in the Media Library? I was able to do that using Divi and Advanced Custom Fields and it just made things much easier. Secondly, is it possible to have 2 or three Featured images in a CPT that display randomly in a gallery for example, so that each time the gallery page is displayed, a different one of the 2 or 3 Featured images from each post is used, so the gallery looks fresh?

Is there any documentation that you are following?
No.

Is there a similar example that we can see?
I can give you access to a site where the 1st question above works but it's a Divi and Advanced Custom Field based site.

What is the link to your site?
hidden link

#1228343

Hi Barry,

Thank you for contacting us and I'll be happy to assist.

>> When a user clicks 'Add New' in an image field inside a CPT post, is it possible
>> to view only images previously uploaded to that CPT post and not all images
>> in the Media Library? I was able to do that using Divi and Advanced Custom
>> Fields and it just made things much easier.

- I'm afraid, this feature is not currently supported by Toolset, but you're welcome to submit it as a feature request at:
https://toolset.com/home/contact-us/suggest-a-new-feature-for-toolset/

>> Secondly, is it possible to have 2 or three Featured images in a CPT that display
>> randomly in a gallery for example, so that each time the gallery page is displayed,
>> a different one of the 2 or 3 Featured images from each post is used, so the
>> gallery looks fresh?

- By default design, WordPress only supports a single featured image for each post, but it is possible to attach more than one image to posts.

All images which are uploaded from within page/post edit screen are automatically attached to it.

If your goal is to show a single random image from a number of selected images, you can follow these steps:

1. Using the "Add Media" button, upload all images that you'd like to attach to your page/post.
( ref: https://wordpress.org/support/article/media-add-new-screen/)

2. Create a new view and set it to show "Media" in "Content Selection" setting.
( screenshot: hidden link )

3. In the view's order settings select "Random order", post limit to "1" and a "Post Parent" filter to show posts that are related to the Post with ID set by the shortcode attribute "wpvchildof".
( screenshot: hidden link )

4. After that you'll be able to call this view in your content to show a single random image from the specified post, as needed:


[wpv-view name="slug-of-the-view" wpvchildof="[wpv-post-id]"]

Notes:
- Please replace "slug-of-the-view" with the actual slug of your view.
- [wpv-post-id] will use the ID of the current post where this shortcode is used and you can add the ID of your desired post manually too.

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar

#1228930

My issue is resolved now. Thank you!