Skip Navigation

[Resolved] img srcset

This thread is resolved. Here is a description of the problem and solution.

Problem:

Pls advice what are my options now. it seems toolset is generating the srcset . is there any custom code to disable the srcset for certain part ?

this is the code:

[wpv-conditional if="( $(wpcf-property-photo) ne '' )"]
    <div class="img2">  
[types field='property-photo' width='200' height='150' size='thumbnail' align='none' resize='crop'][/types]    
    </div>
  [/wpv-conditional]

ps: 925.jpg is the img name

this is the output:

<div class="img2">  
<img src="https://www.site/media/listings/landed-house/925-200x150.jpg" class="attachment-thumbnail" alt="" style="" title="" srcset="https://www.site/media/listings/landed-house/925-200x150.jpg 200w, https://www.site/media/listings/landed-house/925-400x300.jpg 400w, https://www.site/media/listings/landed-house/925-768x576.jpg 768w, https://www.site/media/listings/landed-house/925.jpg 800w" sizes="(max-width: 200px) 100vw, 200px" width="200" height="150">    
 </div>

Solution:

In your case, it is a custom image field, so you can display the image URL directly, for example:

[wpv-conditional if="( $(wpcf-property-photo) ne '' )"]
    <div class="img2">  
[wpv-for-each field="wpcf-property-photo"]
<img src="[types field='property-photo' width='200' height='150' size='thumbnail' align='none' resize='crop' url="true"][/types] ">
[/wpv-for-each]
    </div>
  [/wpv-conditional]

Relevant Documentation:

https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-for-each

Iterate through multiple items in a post meta field and output the enclosed text for each item. Including Types repeating fields.

https://toolset.com/documentation/customizing-sites-using-php/functions/#image

url:
'false'(default) | 'true'
true=output the url of the image instead of the html img tag.

This support ticket is created 6 years, 8 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/Hong_Kong (GMT+08:00)

This topic contains 7 replies, has 2 voices.

Last updated by Luo Yang 6 years, 8 months ago.

Assisted by: Luo Yang.

Author
Posts
#624106

hi, i have the same issue as this topic:
https://toolset.com/forums/topic/thumbnail-generates-full-size/

1. i tried to set to default theme - the srcset still exist.
2. disable all other non toolset front end plugin, - the srcset still exist.

pls advice what are my options now. it seems toolset is generating the srcset . is there any custom code to disable the srcset for certain part ?

thanks.

#624120

Hello,

The thread you mentioned above is a compatibility problem, see the last comment of that thread:
https://toolset.com/forums/topic/thumbnail-generates-full-size/#post-447390
It turns out it was Jetpack's Photon service

I suggest you check these in your website:
1) deactivate other plugins and switch to wordpress default theme
2) Follow our document to display the shortcode [wpv-post-featured-image
]
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-post-featured-image

3) Create a new post, upload the the feature image, and test again.

#624144

Hi Luo. thank you

my problem is totally new but similar to that thread.

my code is :

this is the code:

[wpv-conditional if="( $(wpcf-property-photo) ne '' )"]
    <div class="img2">  
[types field='property-photo' width='200' height='150' size='thumbnail' align='none' resize='crop'][/types]    
    </div>
  [/wpv-conditional]

ps: 925.jpg is the img name

this is the output:

<div class="img2">  
<img src="<em><u>hidden link</u></em>" class="attachment-thumbnail" alt="" style="" title="" srcset="<em><u>hidden link</u></em> 200w, <em><u>hidden link</u></em> 400w, <em><u>hidden link</u></em> 768w, <em><u>hidden link</u></em> 800w" sizes="(max-width: 200px) 100vw, 200px" width="200" height="150">    
 </div>

lets do step by step.
do you any code error ?

i have done what you told me to do, pls refer to my first post.

#624151

In your case, it is a custom image field, so you can display the image URL directly, for example:

[wpv-conditional if="( $(wpcf-property-photo) ne '' )"]
    <div class="img2">  
[wpv-for-each field="wpcf-property-photo"]
<img src="[types field='property-photo' width='200' height='150' size='thumbnail' align='none' resize='crop' url="true"][/types] ">
[/wpv-for-each]
    </div>
  [/wpv-conditional]

More help:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-for-each
Iterate through multiple items in a post meta field and output the enclosed text for each item. Including Types repeating fields.
https://toolset.com/documentation/customizing-sites-using-php/functions/#image
url:
'false'(default) | 'true'
true=output the url of the image instead of the html img tag.

#624155

Thank you , it works as needed.
Didn't know its that simple.

but one question though, my field is not a repeating field, is it ok to use this code ?

#624157

If your are using single instance field, then no [wpv-for-each] needed, for example:

[wpv-conditional if="( $(wpcf-property-photo) ne '' )"]
    <div class="img2">  
<img src="[types field='property-photo' width='200' height='150' size='thumbnail' align='none' resize='crop' url="true"][/types] ">
    </div>
  [/wpv-conditional]
#624158

Thanks

I have another question , ill open another thread for this.

#624461

You are welcome