Voyager
HomeGithubIssues
1.4
1.4
  • Introduction
  • Getting started
    • What is Voyager
    • Prerequisites
    • Installation
    • Upgrading
    • Configurations
  • BREAD
    • Introduction
    • Relationships
    • Formfields
      • Checkbox/Multiple Checkbox/Radio
      • Coordinates
      • Date & Time
      • Dropdown
      • Images
      • Media Picker
      • Number
      • TinyMCE
  • Core concepts
    • Routing
    • Media Manager
    • Menus and Menu Builder
    • Database Manager
    • Settings
    • Compass
    • Roles and Permissions
    • Helper methods
    • Multilanguage
  • Customization
    • Overriding files
    • Overriding Routes
    • Additional CSS and JS
    • Enabling Soft-Delete
    • Custom relationship attributes
    • Adding custom Formfields
    • Coordinates
    • BREAD accessors
    • Custom guard
    • Action buttons
  • Troubleshooting
    • Using HTTPS on yours site
    • Missing required parameter
Powered by GitBook
On this page
  • Thumbnails URL
  • Display a single image
  • Display multiple images
Export as PDF
  1. Core concepts

Helper methods

PreviousRoles and PermissionsNextMultilanguage

Last updated 5 years ago

Voyager has several helper functions that are ready to use. Here you can find the list of available function that may speed up your development.

Thumbnails URL

Voyager will generate thumbnails for Image field type when you specify the .

After you have your thumbnails generated, you may want to display the thumbnails in your view or get the thumbnail URL. In order to do that you need to add Resizable traits to your model.

use TCG\Voyager\Traits\Resizable;

class Post extends Model
{
    use Resizable;
}

Display a single image

@foreach($posts as $post)
    <img src="{{Voyager::image($post->thumbnail('small'))}}" />
@endforeach

Or you can specify the optional image field name (attribute), default to image

@foreach($posts as $post)
    <img src="{{Voyager::image($post->thumbnail('small', 'photo'))}}" />
@endforeach

Display multiple images

@foreach($posts as $post)
    $images = json_decode($post->images);
    @foreach($images as $image)
        <img src="{{ Voyager::image($post->getThumbnail($image, 'small')) }}" />
    @endforeach
@endforeach
additional field options