hej toolset.
i'd like to display a bunch of attachments (fyi: categorized textures and patterns) in a view.
so i am looking for a smart way to receive the attachment urls.
the main part could look like this …
<div class="pattern" style="background:url(my-attachment-url) repeat repeat;">
if found also infos on …
https://developer.wordpress.org/reference/functions/wp_get_attachment_url/
it would be great to have options in what size of the attachment (probably 'thumbnail') the url will lead to.
can you help out with the missing code?
best,
s
With Toolset Views you can display the Featured Image and any Image or File attached to a Post by a Types Field.
Hoover, we do not have a ShortCode for the attachment URL
Anyway, even if you have crafted your own, I can't suggest to use it as a HTML Attribute or CSS attribute.
ShortCodes API is not allowing this.
https://make.wordpress.org/core/2015/07/23/changes-to-the-shortcode-api/
Views does provide it's own ShortCode parser wpv_do_shortcode() to allow some nested usage of ShortCodes, but still we can not really recommend to use ShortCodes for HTML or CSS.
The function you require, is regarding WordPress API, and we do not provide such Custom Code.
We can though point you to the correct Documentation and illustrate how our own API works, along with the native functionality.
https://toolset.com/toolset-support-policy/#getting-help-with-custom-coding
If you want to return URL of things that you can populate with Toolset such as Fields (image and file) or Featured Image URL, you can do that by outputting a RAW value of them using our ShortCodes for it.
In the ScreenShot I illustrate the situation for featured Images.
This is the DOC for the available Fields and ShortCodes:
https://toolset.com/documentation/customizing-sites-using-php/functions/
https://toolset.com/documentation/views-shortcodes/#wpv-post-featured-image
Thank you