Support

Account

Home Forums General Issues Call ACF field value inside Javascript script

Solved

Call ACF field value inside Javascript script

  • Hello I try to make the following script work. It should get the URL & Title Value from ACF fields.

    
    <div id="adobe-dc-view" style="height: 800px; width: 800px;"></div>
    <script src="https://documentcloud.adobe.com/view-sdk/main.js"></script>
    <script type="text/javascript">
    	document.addEventListener("adobe_dc_view_sdk.ready", function(){ 
    		var adobeDCView = new AdobeDC.View({clientId: "<CLIENT ID>", divId: "adobe-dc-view"});
    		adobeDCView.previewFile({
    			content:{location: {url: "https://documentcloud.adobe.com/view-sdk-demo/PDFs/Bodea Brochure.pdf"}},
    			metaData:{fileName: "Bodea Brochure.pdf"}
    		}, {embedMode: "SIZED_CONTAINER"});
    	});
    </script>

    The custom fields ID are:
    File: “dokumente_datei” (return value is set to URL) => It should replace: “https://documentcloud.adobe.com/view-sdk-demo/PDFs/Bodea Brochure.pdf” of the Script.
    Titel: “post-title” => should replace: “Bodea Brochure.pdf”

    Any hints how can I made this work?

  • 
    <div id="adobe-dc-view" style="height: 800px; width: 800px;"></div>
    <script src="https://documentcloud.adobe.com/view-sdk/main.js"></script>
    <script type="text/javascript">
    	document.addEventListener("adobe_dc_view_sdk.ready", function(){ 
    		var adobeDCView = new AdobeDC.View({clientId: "<CLIENT ID>", divId: "adobe-dc-view"});
    		adobeDCView.previewFile({
    			content:{location: {url: "<?php the_field('dokumente_datei'); ?>"}},
    			metaData:{fileName: "<?php the_title(); ?>"}
    		}, {embedMode: "SIZED_CONTAINER"});
    	});
    </script>
    
  • Thanks very much for your help 🙂

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.