> For the complete documentation index, see [llms.txt](https://wpcloudplugins.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wpcloudplugins.gitbook.io/docs/developers/api/create_preview_url.md).

# create\_preview\_url()

## Create a preview url

&#x20; <mark style="background-color:orange;">create\_preview\_url()</mark> &#x20;

Create a preview url for a file. Only available for document formats with preview support.<br>

{% tabs %}
{% tab title="OneDrive" %}

### **Parameters**

<table><thead><tr><th width="196">Name</th><th width="87">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>$id</code></td><td>string</td><td>ID of the entry</td></tr></tbody></table>

### **Return**

<table><thead><tr><th width="194">Name</th><th width="238">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>$url</code></td><td>string</td><td>A preview url to the file</td></tr></tbody></table>

### **Usage**

```php
WPCP_ONEDRIVE_API::set_account_by_id('8c9bacda0-d8d8-4b22-b634-7b5281687575');
WPCP_ONEDRIVE_API::set_drive_by_id('b!DlaHWskCed_MIid3KpJH5Lbatf9HsdXBAZH5YcvPAbMhJUKzTJyzgvXZYpBS');

// Create preview url
$preview_url= WPCP_ONEDRIVE_API::create_preview_url('01EXLSWHWMQZNDMLRG7NFIWAVYCFJAXP2R');
```

{% endtab %}

{% tab title="Google Drive" %}

### **Parameters**

<table><thead><tr><th width="196">Name</th><th width="87">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>$id</code></td><td>string</td><td>ID of the entry</td></tr></tbody></table>

### **Return**

<table><thead><tr><th width="194">Name</th><th width="238">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>$url</code></td><td>string</td><td>A preview url to the file</td></tr></tbody></table>

### **Usage**

```php
WPCP_GDRIVE_API::set_account_by_id('201096615285735764133')

// Create preview url
$preview_url= WPCP_GDRIVE_API::create_preview_url('1wzWlDMsZkA4N5yEEAmMigp52u7M0Lk_7');
```

{% endtab %}

{% tab title="Dropbox" %}

### **Parameters**

<table><thead><tr><th width="185">Name</th><th width="168">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>$id</code></td><td>string</td><td>ID of the entry</td></tr></tbody></table>

### **Return**

<table><thead><tr><th width="184">Name</th><th width="167">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>$url</code></td><td>string</td><td>A preview url to the file</td></tr></tbody></table>

### **Usage**

```php
WPCP_DROPBOX_API::set_account_by_id('dbid:AADSy6JxzbgqCs4A43CAAAfO9xvZwpcsLU');

// Get metadata for the file or folder
$entry = WPCP_DROPBOX_API::get_entry('id:4tUAwPCAdf0b0AAAAA_iw');

// Create preview url
$preview_url= WPCP_DROPBOX_API::create_preview_url('id:4tUAwPCAdf0b0AAAAA_iw');
```

{% endtab %}

{% tab title="Box" %}

### **Parameters**

<table><thead><tr><th width="212">Name</th><th width="93">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>$id</code></td><td>string</td><td>ID of the entry</td></tr></tbody></table>

### **Return**

<table><thead><tr><th width="210">Name</th><th width="96">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>$url</code></td><td>string</td><td>A preview url to the file</td></tr></tbody></table>

### **Usage**

```php
WPCP_BOX_API::set_account_by_id('29232154182');

// Create preview url
$preview_url= WPCP_BOX_API::create_preview_url('51142665')
```

{% endtab %}
{% endtabs %}
