New home › Forums › Pro Add-on › Troubleshooting › Adding front-end custom field labels and changing image-size preset?
Tagged: custom fields, image size
- This topic has 4 replies, 2 voices, and was last updated 1 year, 4 months ago by Matthew.
-
AuthorPosts
-
October 22, 2021 at 4:49 pm #70975[email protected]Participant
You provide the ability to add custom fields, but no way to include a label on those fields for front-end output? I have a few added, but having no label for context makes for a very jumbled and confusing InfoWindow. How might this be achievable?
Additionally — it seems the medium image size is being used with no option to adjust that. How can I have it use one of my pre-defined image sizes instead? (I do NOT simply want to enter a max image width/height as is available at Settings > InfoWindows, because that just squeezes images into the set constraints vs resizing/cropping)
Have you considered restructuring InfoWindows into a template that could be copied into a theme (and then that theme version would overwrite the default within the plugin)? Was expecting to find that flexibility… it’d be great to have more control over these elements.
October 25, 2021 at 4:04 pm #70982MatthewModeratorHi Stacy,
Thank you for getting in touch with us, we do appreciate your time.
Custom Field labels
The labels for custom fields can be achieved with some custom JS code which I have written for you below:jQuery(function($){ $(document).on('infowindowopen.wpgmza', function(){ var infowindow = $('.wpgmza-infowindow'); $('.wpgmza-infowindow p').each(function(){ var pTag = $(this); //console.log(pTag.attr('data-custom-field-id')); if( pTag.attr('data-custom-field-id') == undefined ){ // Dont do anything } else { var custom_field_val = pTag.html(); var custom_field_label = pTag.attr('data-custom-field-name'); var reformatted = '<strong>' + custom_field_label + ': </strong>' + custom_field_val; pTag.html(reformatted); } }); }); })
Please may you copy, paste and save the above JS code into the “Custom JS” setting block (Maps -> Settings -> Advanced Settings)? Once this has been done, please may you confirm if this helps (note that this code is untested as I cannot test it on your site)?
Using uploaded image sizes
This may be achievable by altering some of the core code, however, please note that this will be undone when you update the plugin as it will override the changes. Should you want me to alter the code for you, please may I kindly ask if you may provide me with your email address so that I may reach out to you directly and thus assist you accordingly (You may mark your reply as private should you prefer)?With regards to having more customizability over the infowindows, thank you for the suggestions, we will look into this for the future.
I look forward to hearing back from you.
Kindest Regards,
MatthewNovember 5, 2021 at 3:03 pm #71100[email protected]ParticipantMatthew — I’m SO sorry for the delay, I was expecting an email notification when a response was posted… finally logged back in to followup (since this site needs to launch asap) and turns out you responded! Oops…
I’ve added the JS as instructed but don’t see labels anywhere. Cleared both browser and server cache but still no luck.
As for image sizes/altering the core plugin files, I’m aware of the liability in terms of updating and am perfectly comfortable entering it myself if you can provide the code/let me know where it should be inserted.
Thank you!
November 5, 2021 at 3:05 pm #71101[email protected]ParticipantThis reply has been marked as private.November 8, 2021 at 7:40 am #71114MatthewModeratorHi Stacy,
Thank you for getting back to me and the delay is not a problem at all.
Thank you for your response, I have thus reached out to you directly via our support desk regarding this and how to proceed further.
I look forward to hearing back from you.
Kindest Regards,
Matthew -
AuthorPosts
- You must be logged in to reply to this topic.