Forum

Thread tagged as: Problem, Field-Types

Perch Collection - Not outputting cropped image path. Outputs full image path

Hi,

For ease, I've asked my question via a screencast on YouTube:

https://www.youtube.com/watch?v=lLbkNDj7LiM

In short: I can't get the path of a cropped image to be output in a content template. I'm using Runway and a collection for the data.

/templates/content/car.html

The content template used to create the collection.

<perch:content id="heading" type="text" label="Title" required="true" title="true" />

<perch:content id="make" type="text" label="Make" required="true" />

<perch:content id="model" type="text" label="Model" required="true" />

<perch:content id="submodel" type="text" label="Sub-Model" required="true" />

<perch:content id="price" type="text" label="Price" required="true" />

<perch:content id="milage" type="text" label="Milage" required="true" />

<perch:content id="description" type="textarea" label="Description" required="true" />

<perch:content id="transmission" type="select" label="Transmission" 
options="Manual, Automattic" allowempty="false" required="true" />

<perch:content id="Fuel" type="select" label="Fuel type" 
options="Petrol, Diesel, Electric, Hybrid" allowempty="false" required="true" />

<perch:content type="image" id="featured_car_image" label="Featured image" width="896" height="504" crop="true" bucket="cars" />

<perch:content type="text" id="featured_alt" label="Featured image description" />

<perch:repeater id="images" label="Images" max="4">
    <img src="<perch:content type="image" id="image" label="Image" width="896" height="504" crop="true" bucket="cars" />" 
      alt="<perch:content type="text" id="alt" label="Image description" />" />
</perch:repeater>

<perch:repeater id="spec" label="Specification/Features">
    <perch:content type="text" id="feature" label="Feature" />
</perch:repeater>

/sys/templates/pages/home.php

Within the homepage master template I'm using:

<?php
    perch_collection('Cars', [
        'template' => 'cars/featured.html',
        'sort-order' =>'DESC'
    ]);
?>

Which is pointing at the following:

/sys/templates/content/cars/featured.html

<div class="carousel__item">
    <div class="carousel__item__inner">

        <div class="carousel__item__thumb">
            <img src='<perch:content id="featured_car_image" type="image" width="896" heigh="504" crop="true" bucket="cars" />'>
        </div>

        <p>random text</p>

        <h3 class="carousel__item__title">
            <perch:content id="make" /> &ndash; <perch:content id="model" />
        </h3>

        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Officia nostrum facere placeat ex magnam minus id laudantium veniam saepe, non cumque adipisci ab vero. Vel doloremque, illo saepe soluta dignissimos!</p>

    </div>
</div>

Diagnostic Information:

PERCH INFORMATION

Perch Runway: 2.8.7
Production mode: Production (100)
Installed apps: content (2.8.7), assets (2.8.7), categories (2.8.7), collection_1 (2.8.7)
DB driver: PDO
DB tables: perch2_backup_plans, perch2_backup_resources, perch2_backup_runs, perch2_categories, perch2_category_counts, perch2_category_sets, perch2_collection_index, perch2_collection_items, perch2_collection_revisions, perch2_collections, perch2_content_index, perch2_content_items, perch2_content_regions, perch2_navigation, perch2_navigation_pages, perch2_page_routes, perch2_page_templates, perch2_pages, perch2_resource_tags, perch2_resources, perch2_resources_to_tags, perch2_settings, perch2_user_privileges, perch2_user_role_privileges, perch2_user_roles, perch2_users
Users: 1
App runtimes:
<?php
    $apps_list = array(
        'content', 
        'categories',
    );
Editor plug-ins: markitup
H1: b4bc692e4358ce0cd8eef93ae8733e12
L1: 7562a442659675eb8a40f612888a04d9
headerColour: #3ab44a
content_singlePageEdit: 1
helpURL:
siteURL: /
hideBranding: 1
content_collapseList: 1
lang: en-gb
update_2.8.7: done
headerScheme: dark
update_runway_2.8.7: done
latest_version: 2.8
on_sale_version: 2.8.7
dashboard: 1
hide_pwd_reset: 1
content_hideNonEditableRegions: 1
content_frontend_edit: 0
logoPath: /sys/resources/logo.png
PERCH_DEVELOPMENT: 10
PERCH_STAGING: 50
PERCH_PRODUCTION: 100
PERCH_SITEPATH: /home/repairyourcredit/public_html/dev
PERCH_SCHEDULE_SECRET: mDQDpNpVKqrKupYn
PERCH_DB_USERNAME: repairyo_bcnc
PERCH_DB_SERVER: 87.76.29.29
PERCH_DB_DATABASE: repairyo_bcnc
PERCH_DB_PREFIX: perch2_
PERCH_EMAIL_FROM: mail@airfront.co.uk
PERCH_EMAIL_FROM_NAME: Paul Smith
PERCH_LOGINPATH: /sys
PERCH_PATH: /Users/paulsmith/Sites/bcnc/build/sys
PERCH_CORE: /Users/paulsmith/Sites/bcnc/build/sys/core
PERCH_RESFILEPATH: /Users/paulsmith/Sites/bcnc/build/sys/resources
PERCH_RESPATH: /sys/resources
PERCH_HTML5: 1
PERCH_TZ: Europe/London
PERCH_IMAGE_LIB: imagick
PERCH_RUNWAY: 1
PERCH_ERROR_MODE: DIE
PERCH_DATE_LONG: %d %B %Y
PERCH_DATE_SHORT: %d %b %Y
PERCH_TIME_SHORT: %H:%M
PERCH_TIME_LONG: %H:%M:%S
PERCH_DEBUG:
PERCH_PREVIEW_ARG: preview
PERCH_TEMPLATE_PATH: /Users/paulsmith/Sites/bcnc/build/sys/templates
PERCH_DEFAULT_DOC: index.php
PERCH_DEFAULT_EXT: .php
PERCH_PRODUCTION_MODE: 100
PERCH_RWD:
PERCH_HTML_ENTITIES:
PERCH_SSL:
PERCH_STRIPSLASHES:
PERCH_PROGRESSIVE_FLUSH: 1
PERCH_AUTH_PLUGIN:
PERCH_DB_CHARSET: utf8
PERCH_DB_PORT:
PERCH_DB_SOCKET:
HOSTING SETTINGS

PHP: 5.6.7
Zend: 2.6.0
OS: Darwin
SAPI: apache2handler
Safe mode: not detected
MySQL client: mysqlnd 5.0.11-dev - 20120503 - $Id: 3c688b6bbc30d36af3ac34fdd4b7b5b787fe5555 $
MySQL server: 5.5.42-cll
Extensions: Core, date, ereg, libxml, openssl, pcre, sqlite3, zlib, bcmath, bz2, calendar, ctype, curl, dom, hash, fileinfo, filter, ftp, gd, SPL, iconv, intl, json, ldap, mbstring, session, standard, mysqlnd, mysqli, PDO, pdo_mysql, pdo_sqlite, Phar, posix, Reflection, mysql, SimpleXML, soap, sockets, exif, tokenizer, wddx, xml, xmlreader, xmlwriter, xsl, zip, apache2handler, imap, gettext, mcrypt, yaz, pgsql, pdo_pgsql, imagick
GD: Yes
ImageMagick: Yes
PHP max upload size: 32M
PHP max form post size: 32M
PHP memory limit: 128M
Total max uploadable file size: 32M
Resource folder writeable: Yes
Session timeout: 24 minutes
Native JSON: Yes
Filter functions: Yes
Transliteration functions: Yes
HTTP_HOST: bcnc:8000
HTTP_CONNECTION: keep-alive
HTTP_ACCEPT: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
HTTP_USER_AGENT: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.81 Safari/537.36
HTTP_DNT: 1
HTTP_REFERER: https://bcnc:8000/sys/core/settings/diagnostics/
HTTP_ACCEPT_ENCODING: gzip, deflate, sdch
HTTP_ACCEPT_LANGUAGE: en-US,en;q=0.8
HTTP_COOKIE: cmsa=1; PHPSESSID=c342db7982061b3be028933b916896ba; _ga=GA1.1.175384965.1432919598
PATH: /usr/bin:/bin:/usr/sbin:/sbin
SERVER_SOFTWARE: Apache
SERVER_NAME: bcnc
SERVER_ADDR: ::1
SERVER_PORT: 8000
REMOTE_ADDR: ::1
DOCUMENT_ROOT: /Users/paulsmith/Sites/bcnc/build
SERVER_ADMIN: you@example.com
SCRIPT_FILENAME: /Users/paulsmith/Sites/bcnc/build/sys/core/settings/diagnostics/index.php
REMOTE_PORT: 53829
GATEWAY_INTERFACE: CGI/1.1
SERVER_PROTOCOL: HTTP/1.1
REQUEST_METHOD: GET
QUERY_STRING: extended
REQUEST_URI: /sys/core/settings/diagnostics/?extended
SCRIPT_NAME: /sys/core/settings/diagnostics/index.php
PHP_SELF: /sys/core/settings/diagnostics/index.php
REQUEST_TIME_FLOAT: 1433327172.13
REQUEST_TIME: 1433327172
argc: 1
Paul Smith

Paul Smith 0 points

  • 6 years ago

There's a typo in your featured.html

heigh="..."

instead of

height="..."

Hmmm. Didn't fix things but you have me thinking along the right lines. I'm running a gulp watch task that might be meddling with things. It shouldn't be but I wonder if there is some kind of race condition? I'll double check and report back.

Sigh... I've been working too much.. The typo combined with a broken watch task meant that I missed another typo elsewhere. Carry on being awesome and I'll go for a sleep.

Drew McLellan

Drew McLellan 2638 points
Perch Support

You're missing type="image" - Perch doesn't know it's an image fieldtype, so just outputs the most basic form of the stored content, the original path.

You almost always need to set the type attribute so that the correct fieldtype is invoked.