Contents
On this page

Preview CSV - Plugixa Image Map

POST /plugixa-image-map/v1/csv/preview

Read a CSV of hotspots and report what an import would make of it, without creating anything.

Any signed-in user with both plugixa_image_map_import and plugixa_image_map_create. See Roles and permissions. Needs Plugixa Image Map Pro: on the free build this route does not exist and answers 404.

Request

POST https://your-site.example/wp-json/plugixa-image-map/v1/csv/preview

Request body

Content type: application/json

Field Type Required Description
csv string Yes The file’s contents.

The first row names the columns, in any order and any case. Commas, semicolons or tabs all work: the separator is the one the first row uses most. Columns the reader does not know are listed in ignored.

Column Also accepted Meaning
x, y Required. The hotspot’s centre in percent of the picture, 0 to 100. A comma decimal and a % sign are accepted.
type shape spot (the default; also point, pin, marker), rect (rectangle, square, box) or oval (circle, ellipse).
name title, label The hotspot’s name, up to 100 characters.
width, height w, h Size in percent. A shape without them is 10 by 10.
tooltip description, text Plain text becomes paragraphs; text containing < is kept as HTML and filtered.
link url Must start with http:// or https://.
category group Hotspots with the same category share a layer group.

The file may be 1 MB at most and only the first 2,000 usable rows are read. See CSV import.

{
  "csv": "name,x,y,tooltip,link,category\nReception,42.5,61.25,Open 8:00 to 18:00,https://your-site.example/visit,Services\nCafe,70,30,,,Food\n"
}

Responses

200 OK. data is what the reader found.

{
  "success": true,
  "data": {
    "rows": [
      {
        "line": 2,
        "name": "Reception",
        "x": 42.5,
        "y": 61.25,
        "type": "spot",
        "w": null,
        "h": null,
        "tooltip": "Open 8:00 to 18:00",
        "link": "https://your-site.example/visit",
        "category": "Services"
      },
      {
        "line": 3,
        "name": "Cafe",
        "x": 70.0,
        "y": 30.0,
        "type": "spot",
        "w": null,
        "h": null,
        "tooltip": "",
        "link": "",
        "category": "Food"
      }
    ],
    "problems": [],
    "ignored": []
  }
}
Field Type Meaning
data.rows[] array The usable rows, with the line they came from and their values read as the import would use them. w and h are null when not given
data.problems[] array { "line", "message" } for each row that was skipped, and why
data.ignored[] string[] Column names that were not recognised

Errors

Status Code When
413 plugixa_image_map_csv_too_large The CSV is over 1 MB.
422 plugixa_image_map_csv_columns The first row has no x or no y column. An empty csv ends here too.

Plus the errors every endpoint can return.

Examples

curl -s -X POST "https://your-site.example/wp-json/plugixa-image-map/v1/csv/preview" \
  -u "admin:$WP_APP_PASSWORD" \
  -H "Content-Type: application/json" \
  -d '{"csv":"name,x,y,tooltip,link,category\nReception,42.5,61.25,Open 8:00 to 18:00,https://your-site.example/visit,Services\nCafe,70,30,,,Food\n"}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-image-map/v1/csv/preview');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST  => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_USERPWD        => 'admin:' . getenv('WP_APP_PASSWORD'),
    CURLOPT_HTTPHEADER     => ['Content-Type: application/json'],
    CURLOPT_POSTFIELDS     => json_encode([
        'csv' => 'name,x,y,tooltip,link,category
Reception,42.5,61.25,Open 8:00 to 18:00,https://your-site.example/visit,Services
Cafe,70,30,,,Food
',
    ]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-site.example/wp-json/plugixa-image-map/v1/csv/preview', {
  method: 'POST',
  headers: {
    'Authorization': 'Basic ' + btoa(`admin:${process.env.WP_APP_PASSWORD}`),
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    csv: 'name,x,y,tooltip,link,category
Reception,42.5,61.25,Open 8:00 to 18:00,https://your-site.example/visit,Services
Cafe,70,30,,,Food
',
  }),
});
const { data } = await response.json();

Quick Links

Share