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
- How do I redirect to another webpage?
- How do I check whether a checkbox is checked in jQuery?
- Uncaught SyntaxError: Invalid or unexpected token
- My javascript is returning this error: $.ajax is not a function
- Unable to preventDefault inside passive event listener
- jQuery $.cookie is not a function
- Setting background-image using jQuery CSS property
- Scroll Automatically to the Bottom of the Page
- How do I check if string contains substring?
- How can I select an element by name with jQuery?
- JQuery issue “TypeError: $.getJSON is not a function”
- SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data
- How do I select text nodes with jQuery?
- JQuery get the title of a button
- Trying to load jquery into tampermonkey script
- Preloading images with jQuery
- Simulate a click on ‘a’ element using javascript/jquery
- How can I remove a style added with .css() function?
- Get Image Description
- Automatically replace original uploaded image with large image size
- How to scale up featured post thumbnail?
- Custom image size / thumbnail – Crop to aspect ratio even when source image is smaller than set dimensions
- wp_get_attachment_image_src and server path
- Change WordPress image URLs via filter
- How to resize images in wordpress without adding any compression or changing the color profile of the images, possible?
- Automatically decrease font size for long words
- hook into completed image upload filter
- Dynamically update post title in admin page
- Why is wp_get_attachment_image not including “full” size in srcset?
- Get img alt tag from a Image that has been uploaded through the Customizer
- Get Attachment ID from URL [duplicate]
- How to add a “data-” attribute to the image tag of native gallery output
- How to set twenty fourteen header image at 100% width?
- Can’t Display Featured Image in RSS Feed
- Filter to modify post_title after image upload?
- Automatically Add Caption in image
- Import Images from one self-hosted WordPress install to another
- How to Optimize images after uploading all images to WordPress Site?
- How to get relative URL of medium sized featured image?
- How do i reference the theme path in pages for images?
- Using srcsets to load different images based on browser widths
- Multiple entries for one object with different cover images
- How to exclude an image size from the WordPress srcset
- Access/update database with jQuery
- WordPress Jquery Fade in, Fade out effect
- Gutenberg editor get post featured image by id
- Local WordPress installation doesn’t crop images
- Ajax return code 400
- Add custom setting that uses radio button to WP Gallery
- Get full URL of images in media library including http://
- Host images only on CDN
- Generating different dimension images while uploading image file from custom plugin page
- No data received
- How to intigrate multiple image uploader in a custom post type
- Stripping the_content() from images then displaying them seperately
- Image upload appearing as broken images following server move
- Regex expression for redirecting image URLs to another folder
- CodeMirror on Custom Widget Textarea
- Sending click events to Google Analytics in WordPress: the easy way
- How to search using ajax for exact phrase or words in an input field?
- Background image resets after time (XAMPP)
- renaming an image automatically everywhere else (posts and pages)
- How to: JQuery multiple wordpress media uploader buttons in the same options page?
- Custom thumbnail size of image when uploaded
- Access Customizer widget instance form
- Change wp-content/uploads to uploads/%postname%/%image%
- Add suffix to uploaded images