I am trying to:
I've recently converted my website from HTTP to HTTPS. However, despite updating all URLs in the database, Types seems to be ignoring the URL and always defaulting to HTTP.
I tried the no_protocol property and this has no effect either.
<?php echo(types_render_field("customer-photo", array("alt"=>"Case Study Photo","width"=>"100","height"=>"100","proportional"=>"false","no_protocol"=>"true"))); ?>
Link to a page where the issue can be seen:
lien caché
There is a tag that looks like this, which should be HTTPS.
<img alt="Case Study Photo" src="<em><u>lien caché</u></em>">
I realize it's a CDN URL, but I've tested this locally without the CDN and it still only displays HTTP instead of HTTPS.
I expected to see:
An HTTPS URL to the image asset.
Instead, I got:
An HTTP URL to the image asset.
Dear DM,
Types function types_render_field() can only display the image URL same as you setup it in the wordpress admin side, for example, you can edit the post:
lien caché
Find the custom field "customer-photo", you should be able to see the value of it, make sure it is using HTTPS schema too.
Please let me know if you need more assistance for it. thanks
Hi Luo,
I understand what you mean and that's what I thought too until I did a little debugging. I can confirm that the URL in the 'customer-quote-photo' custom field is an HTTPS one (see attachment).
This code...
<?php echo(types_render_field("customer-photo", array("alt"=>"Case Study Photo"))); ?>
Products this tag...
<img alt="Case Study Photo" src="<em><u>lien caché</u></em>">
This code...
<?php echo(types_render_field("customer-photo", array("alt"=>"Case Study Photo","width"=>"100","height"=>"100","proportional"=>"false","no_protocol"=>"true"))); ?>
Produces this tag...
<img alt="Case Study Photo" src="<em><u>lien caché</u></em>">
Notice how when I use the width/height/proportional parameters, it appends the "-wpcf_100x100.jpg" to the filename and changes the URL to HTTP ignoring the "no_protocol" flag.
Maybe I'm missing something?
Thanks for the details, I can duplicate same problem in my localhost, the attribute "no_protocol"=>"true" does not works as expected, I put it into our to-do list, our developers will take care of it.
Currently, you can try this:
Use filter hook of Types plugin to remove the protocol of image URL, for example, add below codes into your theme/functions.php, and test again:
add_filter( 'wpcf_fields_type_image_value_display', 'my_fields_no_protocol_parser', 10, 4 );
function my_fields_no_protocol_parser($value, $params, $post, $meta){
if($meta == 'customer-photo'){
$value = wpcf_fields_no_protocol_parser($value, $params, $post, $meta);
}
return $value;
}
Here is the feedback from our 2nd tier supporters:
The attribute no_protocol is not present for Image Fields.
This attribute is only for URL fields.
And our document has been updated:
https://toolset.com/documentation/customizing-sites-using-php/functions/#image
Understood. Will they be addressing the fact that it does not honor the HTTP/HTTPS settings for the field? This could present a notable problem to sites that want to be HTTPS only, resulting in mix-content messages to end users and in some cases, depending on browser, not rendering the content.
For this question:
Will they be addressing the fact that it does not honor the HTTP/HTTPS settings for the field?
I can not duplicate same problem, I suggest you check these:
1) Dashboard-> Settings-> General
Setup the both HomeURL and SiteURL as HTTPS settings, for example:
lien caché
2) Deactivate other plugins and switch to wordpress default theme, and test again,
3) And I have already provide you a workaround which can output the image URL without protocol, see here:
https://toolset.com/forums/topic/the-no_protocol-property-does-not-work-with-image-fields/#post-567064
Hi Luo,
Thanks for following up. As it turns out, the setting I needed to change was the default URL for WordPress so that it was using HTTPS instead of HTTP. Sorry about that. All issues resolved, thanks for your help!