Skip to content

Instantly share code, notes, and snippets.

@sanderpotjer
Created December 19, 2017 09:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sanderpotjer/aadf689d49b14ef7b85739445520a461 to your computer and use it in GitHub Desktop.
Save sanderpotjer/aadf689d49b14ef7b85739445520a461 to your computer and use it in GitHub Desktop.
PWT Image dev-docs

Form field

The form field is used like this:

<fieldset name="images" addfieldpath="components/com_pwtimage/models/fields">
	<field
		name="image"
		type="pwtimage.image"
		label="COM_PWTIMAGE_FIELD_PHOTO_LABEL"
        description="COM_PWTIMAGE_FIELD_PHOTO_DESC"
		ratio="16/9"
		multiple="false"
		showTools="true"
		gallery="false"
	/>
</fieldset>

Field options

The form field takes several options

  • name This is the name of the field. When using multiple images, the name must be appended with []

  • type This is always pwtimage.image

  • label A language string to give the field a label. Set the language string in the language file of your extension.

  • description A language string to give the field a description. Set the language string in the language file of your extension.

  • ratio This is the ratio to use for cropping the image. This must be in the format of width/height. For example 16/9.

  • multiple Set this to true to allow multiple images to be added.

  • width Set the fixed width of an image

  • sourcePath Set the source folder where the images are to be stored. This setting will override the Source Path set in the Global Configuration.

  • subPath Set the subfolder where to store the images, this is appended to the sourcePath. This setting will override the Subfolder path in the Global Configuration. The placeholders {year} and {month} can be used here as well.

  • showFolder Turns the use of the local folder selection on or off. By default this is enabled.

  • showFolder Shows or hides the path where the image(s) are stored. By default this is enabled.

  • showTools Shows or hides the rotation tools. By default this is enabled.

  • activePage Set which page should be active upon opening the modal. The available options are:

    • upload

    • folder

    • gallery Set if the gallery option should be shown. This is only applicable to the editor button.

    By default the upload page will be shown.

Global configuration

The global configuration contains the settings for where the images are stored, how subfolders should be named and how the filename should be constructed. To set the options go to Components -> PWT Image and click on the Options button. This will take you to the global configuration where you can set the image path and subfolder path. The following placeholders can be used:

Placeholder Description
{name} The name of the original file
{random} A set of random characters
{year} This is replaced with the current year e.g. 2017
{month} This is replaced with the current month in digits e.g. 02
{Y} Year in 4 digits e.g. 2017
{y} Year in 2 digits e.g. 17
{F} A full textual representation of a month e.g. January
{m} Numeric representation of a month, with leading zeros e.g. 01
{M} A short textual representation of a month, three letters e.g. Jan
{n} Numeric representation of a month, without leading zeros e.g. 1
{d} Day of the month, 2 digits with leading zeros e.g. 01
{D} A textual representation of a day, three letters e.g. Mon
{j} Day of the month without leading zeros e.g. 1
{l} A full textual representation of the day of the week e.g. Monday
{W} ISO-8601 week number of year, weeks starting on Monday
{g} 12-hour format of an hour without leading zeros e.g. 1 through 12
{G} 24-hour format of an hour without leading zeros e.g. 0 through 23
{h} 12-hour format of an hour with leading zeros e.g. 01 through 12
{H} 24-hour format of an hour with leading zeros e.g. 00 through 23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment