2017 © Pedro Peláez
 

olympus-field olympus-upload-field

[READ-ONLY] Upload field, this component is a part of the Olympus Zeus Core framework.

image

getolympus/olympus-upload-field

[READ-ONLY] Upload field, this component is a part of the Olympus Zeus Core framework.

  • Saturday, March 17, 2018
  • by crewstyle
  • Repository
  • 1 Watchers
  • 0 Stars
  • 176 Installations
  • HTML
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 7 Versions
  • 0 % Grown

The README.md

Dionysos Upload Field

This component is a part of the Olympus Dionysos fields for WordPress.
It uses the default wpMedia WordPress javascript bundle to manage field., (*1)

composer require getolympus/olympus-dionysos-field-upload

Olympus Component ![CodeFactor Grade][codefactor-image] Packagist Version ![MIT][license-image], (*2)


, (*3)


Field initialization

Use the following lines to add a upload field in your WordPress admin pages or custom post type meta fields:, (*4)

return \GetOlympus\Dionysos\Field\Upload::build('my_upload_field_id', [
    'title'       => 'What\'s your flavor?',
    'can_upload'  => false,
    'default'     => [],
    'description' => 'Tell me what\'s your flavour!',
    'multiple'    => false,
    'type'        => 'image',
    'size'        => 'thumbnail',

    /**
     * Texts definition
     * @see the `Texts definition` section below
     */
    't_addblock_description'  => 'Click on the "+" button to add a media.',
    't_addblocks_description' => 'Click on the "+" button to add medias.',
    't_cannot_upload'         => 'It seems you are not able to upload files.',
    't_name_label'            => 'Edit the legend',
    't_addblock_label'        => 'Add',
    't_editblock_label'       => 'Edit',
    't_removeblock_label'     => 'Remove',
]);

Variables definition

Variable Type Default value if not set Accepted values
title String 'Upload' empty
can_upload Boolean false true or false
default Array empty empty
description String empty empty
multiple Boolean false true or false
type String 'image' default file mime types
size String 'thumbnail' image sizes from add_image_size() WordPress function

Notes: * can_upload value is defined thanks to current_user_can('upload_files') (see WordPress reference) * Set multiple to true to enable the "Add medias" button, (*5)

Texts definition

Code Default value Definition
t_addblock_description Click on the "+" button to add a media. Main helper to add a single item box
t_addblocks_description Click on the "+" button to add medias. Main helper to add multiple items boxes
t_cannot_upload It seems you are not able to upload files. Error displayed if user cannot upload files
t_name_label Edit the legend Name item's placeholder
t_addblock_label Add Used as an Add button area title
t_editblock_label Edit Used as an Edit button area title
t_removeblock_label Remove Used as a Remove button area title

Retrive data

Retrieve your value from Database with a simple get_option('my_upload_field_id', []) (see WordPress reference). Below, a json_encode() example to understand how data are stored in Database:, (*6)

{
  "mediaId": {
    "name": "mediaName.mediaExt",
    "id": "mediaId",
    "height": "mediaHeight",
    "url": "mediaUrl",
    "width": "mediaWidth"
  }
}

And below, a simple example to show how to iterate on the data array in PHP:, (*7)

// Get upload from Database
$upload = get_option('my_upload_field_id', []);

if (!empty($upload)) {
    foreach ($upload as $img) {
        echo '<figure id="'.$img['id'].'">';
        echo '<img src="'.$img['url'].'" width="'.$img['width'].'" height="'.$img['height'].'" alt="'.esc_html($img['name']).'" />';
        echo '<figcaption>'.$img['name'].'</figcaption>';
        echo '</figure>';
    }
}

Release History

0.0.16 - Remove useless admin scripts, (*8)

0.0.15 - Display now compatible with new Zeus-Core version, (*9)

0.0.14 - New Olympus components compatibility - Change repository to be a part of Dionysos fields, (*10)

Contributing

  1. Fork it (https://github.com/GetOlympus/olympus-dionysos-field-upload/fork)
  2. Create your feature branch (git checkout -b feature/fooBar)
  3. Commit your changes (git commit -am 'Add some fooBar')
  4. Push to the branch (git push origin feature/fooBar)
  5. Create a new Pull Request

Built with ♥ by Achraf Chouk ~ (c) since a long time., (*11)

The Versions

17/03 2018

dev-master

9999999-dev https://github.com/GetOlympus/olympus-upload-field

[READ-ONLY] Upload field, this component is a part of the Olympus Zeus Core framework.

  Sources   Download

MIT

The Requires

 

The Development Requires

framework php upload field olympus zeus hera

17/03 2018

v0.0.6

0.0.6.0 https://github.com/GetOlympus/olympus-upload-field

[READ-ONLY] Upload field, this component is a part of the Olympus Zeus Core framework.

  Sources   Download

MIT

The Requires

 

The Development Requires

framework php upload field olympus zeus

08/10 2016

v0.0.5

0.0.5.0 https://github.com/GetOlympus/olympus-upload-field

[READ-ONLY] Upload field, this component is a part of the Olympus Hera WordPress library.

  Sources   Download

MIT

The Requires

 

The Development Requires

framework php upload field olympus hera

26/06 2016

v0.0.4

0.0.4.0 https://github.com/GetOlympus/olympus-upload-field

[READ-ONLY] Upload field, this component is a part of the Olympus Hera WordPress library.

  Sources   Download

MIT

The Requires

 

The Development Requires

framework php upload field olympus hera

10/05 2016

v0.0.3

0.0.3.0 https://github.com/GetOlympus/olympus-upload-field

[READ-ONLY] Upload field, this component is a part of the Olympus Hera WordPress library.

  Sources   Download

MIT

The Requires

 

The Development Requires

framework php upload field olympus hera

05/05 2016

v0.0.2

0.0.2.0 https://github.com/GetOlympus/olympus-upload-field

[READ-ONLY] Upload field, this component is a part of the Olympus Hera WordPress library.

  Sources   Download

MIT

The Requires

 

The Development Requires

framework php upload field olympus hera

29/04 2016

v0.0.1

0.0.1.0 https://github.com/GetOlympus/olympus-upload-field

[READ-ONLY] Upload field, this component is a part of the Olympus Hera WordPress library.

  Sources   Download

MIT

The Requires

 

The Development Requires

framework php upload field olympus hera