This is the example how to add simple Google Maps field type. Could you please use it as a reference. Using above example you can create your own types custom field type.
This support ticket is created 8 years, 1 month 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.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
I`m using an image field on a custom post in Types. But I don`t want to get the URL of the image, but the id of the image post.
I read here https://toolset.com/forums/topic/how-to-get-id-of-image/ that this is possible by querying the id from the URL using the GUID. In my opinion, this is a dodgy way of doing this:
I can not rely on the GUID and the image URL to stay the same. The image url could have changed by domain changes, using https instead of http or plugins like hidden link or hidden link.
So my questions are:
1) Is an image/file field planned, which saves the id instead of the URL?
2) Is it possible to write my own custom fields for Types plugin? This would be a great way, and I could use types for everything.
A bit of background info: I`m trying to get rid of advanced custom fields, because it is not fully WPML compatible and using it combined with types causes some usability problems. But the Types field api does not give me the full option palette what ACF does.
Hello. Thank you for contacting the Toolset support.
So my questions are:
1) Is an image/file field planned, which saves the id instead of the URL?
=> This feature request is already been escalated to our developers and you will see its implemented in near future release. However I do not have any ETA on this.
2) Is it possible to write my own custom fields for Types plugin? This would be a great way, and I could use types for everything.
=> For now, you can use custom code.
Please give me a better answer to question 2:
a) This is not an answer to my question
b) I linked the ticket you pointed to in my post already. With an explanation why I think that this is the wrong way of doing this.
As you can see, with image field we do not have such attribute which will return you the ID of image. But as I said, its already in implementation and with our developer's to do's list and they will soon implemented it and it will be officially made available in near future release so that:
you can fetch:
- image file name
- or image filename with link,
- or image title
- or image title with link
- or image id
b) I linked the ticket you pointed to in my post already. With an explanation why I think that this is the wrong way of doing this.
=> Yes - you are right as well. Types used to store custom fields values to "post_meta" table.
If you navigate to:
=> Plugins/types/embedded/includes/examples/google_map.php
This is the example how to add simple Google Maps field type. Could you please use it as a reference. Using above example you can create your own types custom field type.