• Home
  • Jobs
  • Courses
  • Questions
  • Teachers
  • For business
  • ES/EN

0

73
Views
How to create a Wordpress, Site-origin widget default or preset image value?

I am trying to build an stylable widget that loads with preset or default styling values when introduced to a page. I have been able to utilize default=”” within the form fields to achieve this effect on all buttons and text. But I am trying to establish a background image that will load in initially and allow the user to change the image through the provided fields. Is there a way to set a default image value in my field setting to achieve this functionality? I have provided my attempt below to better demonstrate my goal.

‘fields’ => [
 ‘image’ => [
   ‘type’ => ‘media’,
   ‘label’ => __(‘Image’, ‘widgets-bundle’),
   ‘choose’ => __(‘Choose image’, ‘widgets-bundle’),
   ‘update’ => __(‘Set image’, ‘widgets-bundle’),
   ‘default’ => ‘exampel.org/wp- 
    content/uploads/2021/05/randomimage_2560x890.jpg’,
   ‘library’ => ‘image’,
   ‘fallback’ => true,

],
...
]

Thank you!

2 months ago ·

Santiago Trujillo

1 answers
Answer question

0

Unfortunately, the Media Field doesn't currently support defaults at this time. Your best bet for doing this would be to either create a custom field that allows for this, or alter the base custom field using the siteorigin_widgets_field_registered_class_paths hook. That hook allows you to override the base form field main file with a file of your choosing so you can use it to introduce additional features or control defaults. The documentation for this filter is still pending, but you can find the current version here.

2 months ago · Santiago Trujillo Report
Answer question
Find remote jobs
Loading

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post job Plans Our process Sales
Legal
Terms and conditions Privacy policy
© 2022 PeakU Inc. All Rights Reserved.