You don’t specify how precisely your JS is output. If you are doing this inline from PHP you could just echo required data in place.
If it’s just some arbitrary script, loaded as such, then the common practice in WP is to use wp_localize_script()
to pass data from PHP runtime to an enqueued script.
While by initial purpose (and name) the function was meant for localization, it handles arbitrary data just fine.
Related Posts:
- show hide image script after 4 seconds [closed]
- Set default image link target in Gutenberg image block
- How to modify image editor dialog options on WordPress?
- Graphing libraries for WordPress [closed]
- 3.5 media.editor: what is the event listener for choosing an image?
- JavaScript and images files are not recognized
- Multiple images with Media Uploader on front-end
- Update an image block style programatically
- How can I use cached images in an AJAX response?
- Help to upload post attachments from Ajax
- Image LazyLoad plugin not loading jQuery dependancies with wp_enqueue_script in WP 3.3.1
- How to use Facebox in WordPress theme?
- Howto use WP built in Thickbox for images?
- How to get the image-URL from Media-Upload in a post?
- Using jQuery to automatically add class only to gif images in WordPress database [closed]
- How do I include javascript/jquery image resizing with wordpress?
- Fancybox just loading small white square
- Image modification
- Hide Title tag on image Hover
- Landing Page with HTML CSS JS and Images on wordpress
- Built-in image lazy loading: Does it come with a polyfill for older browsers?
- Access html element in media modal with jQuery
- Images names not inserting in WordPress Database from Dynamic Add / Remove fields
- js alert in add_filter function for image_send_to_editor
- WordPress Javascript displaying an image Question
- Issues Adding a jQuery Image Slider
- Select image and display from textfield?
- Thickbox not displaying just the image, instead showing full page in lightbox
- 3.5.x Theme Customize: Handling Custom Control Requests
- WordPress: Preload next post images
- Theme using masonry layout script rendering overlaped images in Google Chrome [closed]
- Script not working in WordPress [duplicate]
- ‘Add Media’ to post – filter images
- Is possible to open directly the core WP image editor on a modal?
- Include WooCommerce 2’s prettyphoto scripts on all site pages
- I want to Add My Product Image to Admin Order Email in Woocommerece [closed]
- Get custom thumbnail sizes [duplicate]
- I have no images in an activated wp theme
- Remove height attribute from wp_get_attachment
- “Conflict” with jQuery (or its plugins)?
- Mass crop images: Landscape images -> Portrait images
- How do I retrieve an image’s width and height using Advanced Custom Fields?
- Using Jetpack carousel w/o creating a gallery [closed]
- url – ajax loaded but no JS
- wp get attachment image always gives me thumbnail
- Change image name during uploading sequentially
- Filter for post_thumbnail: link to small src and add data-attribute [duplicate]
- Two “the_excerpt” questions
- Store in media library image uploaded from url
- Why does WP allow to view and media item as a page
- should i be checking for jquery before enqueing it in a plugin
- Bulk-add featured images in posts with no featured image
- is_page_template() written in jquery/javascript
- How to limit the number of images displayed in the media window?
- Console Browser says it cannot find a requested image that does not exist on my Website [closed]
- How to get the Gallery form/section just like in Gutenberg block?
- Bulk Upload Image Alt Text
- Upload media only to DB
- Error – ‘create_function is deprecated’ [closed]
- Call to undefined function wp_generate_attachment_metadata()
- Custom Post Type Slick Slider “$ is not a function”
- Should I not compress my jpeg files before uploading to avoid double compression?
- Add clickable link on an image
- Image editor is not loading
- What are the advantages/disadvantages of using jQuery DOM manipulation as opposed to PHP DOM manipulation?
- Cannot use characters ” in jQuery script in WordPress
- Why WordPress strips scr string from img tag off?
- How to know what size image to use for background? [closed]
- WP Customizer compare and set a value via javascript
- Where do I locate theme image files
- Random image loader
- Understanding WordPress image sizes and responsive images
- Image large size [closed]
- WordPress Facebook Open Graph plugin not working for 1 specific image [closed]
- Remove Image Sizes in Media Settings Page
- How to fix a missing image
- Custom responsive ‘featured image’ sizes
- Callback After WordPress Customizer Complete Loading
- Media gallery images url instead of ID on WP API Response
- Adding a Calculator to a WordPress Page
- Modify RSS – remove image and add text
- How to get image from media library with URL [duplicate]
- “JQMIGRATE: Migrate is Installed” How do I find the problem code? [duplicate]
- Is it save to use eval for a jQuery callback method coming from the database?
- One of my image sizes isn’t showing up in srcset
- Is it possible to preserve original images in order to change image size later?
- Referrer URL with jQuery or Javascript – Cache & Referrer URL Issue
- Jquery window.send_to_editor function
- Conflict with single and double quotes
- Why doesn’t jQuery use $, and how can I get it do so (GLOBALLY)?
- How to make my site use HTTPS for images or how to insert images as relative paths?
- the_post_thumbnail(‘medium’) setting some images width=1 height=1
- How to remove header images from displaying (not css or editing)?
- HowTo: develop WP template with dynamic background image
- Generating a certain sized thumbnail on the fly?
- Help with resizing of featured images on WooCommerce homepage
- wordpress add_action() issue in ajax call
- Images give 404 after changing default domain
- How do you import images from a URL in your post?
- How to display title of attached image in post?