Skip Navigation

[Gelöst] The no_protocol property does not work with image fields

The Toolset Community Forum is closed, for technical support questions, please head on to our Toolset Professional Support (for paid clients), with any pre-sale or admin question please contact us here.
This support ticket is created vor 6 Jahre, 7 Monate. There's a good chance that you are reading advice that it now obsolete.
This is the community support forum for Types plugin, which is part of Toolset. Toolset is a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.

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 8 Antworten, has 2 Stimmen.

Last updated by DM vor 6 Jahre, 7 Monate.

Assisted by: Luo Yang.

Author
Artikel
#566138

DM

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:

hidden link

There is a tag that looks like this, which should be HTTPS.

<img alt="Case Study Photo" src="<em><u>hidden link</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.

#566348

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:
hidden link

Find the custom field "customer-photo", you should be able to see the value of it, make sure it is using HTTPS schema too.

#566352

Please let me know if you need more assistance for it. thanks

#566991

DM
custom field link.png

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>hidden link</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>hidden link</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?

#567064

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;
}

#567119

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

#567174

DM

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.

#567409

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:
hidden link

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

#567411

DM

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!

Das Forum „Types Community Support“ ist für neue Themen und Antworten geschlossen.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.