本文整理汇总了PHP中image_style_options函数的典型用法代码示例。如果您正苦于以下问题:PHP image_style_options函数的具体用法?PHP image_style_options怎么用?PHP image_style_options使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了image_style_options函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testResponsiveImageAdmin
/**
* Test responsive image administration functionality.
*/
public function testResponsiveImageAdmin()
{
// We start without any default styles.
$this->drupalGet('admin/config/media/responsive-image-style');
$this->assertText('There is no Responsive image style yet.');
// Add a new responsive image style, our breakpoint set should be selected.
$this->drupalGet('admin/config/media/responsive-image-style/add');
$this->assertFieldByName('breakpoint_group', 'responsive_image_test_module');
// Create a new group.
$edit = array('label' => 'Style One', 'id' => 'style_one', 'breakpoint_group' => 'responsive_image_test_module', 'fallback_image_style' => 'thumbnail');
$this->drupalPostForm('admin/config/media/responsive-image-style/add', $edit, t('Save'));
// Check if the new group is created.
$this->assertResponse(200);
$this->drupalGet('admin/config/media/responsive-image-style');
$this->assertNoText('There is no Responsive image style yet.');
$this->assertText('Style One');
$this->assertText('style_one');
// Edit the group.
$this->drupalGet('admin/config/media/responsive-image-style/style_one');
$this->assertFieldByName('label', 'Style One');
$this->assertFieldByName('breakpoint_group', 'responsive_image_test_module');
$this->assertFieldByName('fallback_image_style', 'thumbnail');
$cases = array(array('mobile', '1x'), array('mobile', '2x'), array('narrow', '1x'), array('narrow', '2x'), array('wide', '1x'), array('wide', '2x'));
foreach ($cases as $case) {
// Check if the radio buttons are present.
$this->assertFieldByName('keyed_styles[responsive_image_test_module.' . $case[0] . '][' . $case[1] . '][image_mapping_type]', '');
// Check if the image style dropdowns are present.
$this->assertFieldByName('keyed_styles[responsive_image_test_module.' . $case[0] . '][' . $case[1] . '][image_style]', '');
// Check if the sizes textfields are present.
$this->assertFieldByName('keyed_styles[responsive_image_test_module.' . $case[0] . '][' . $case[1] . '][sizes]', '');
// Check if the image styles checkboxes are present.
foreach (array_keys(image_style_options(FALSE)) as $image_style_name) {
$this->assertFieldByName('keyed_styles[responsive_image_test_module.' . $case[0] . '][' . $case[1] . '][sizes_image_styles][' . $image_style_name . ']');
}
}
// Save styles for 1x variant only.
$edit = array('label' => 'Style One', 'breakpoint_group' => 'responsive_image_test_module', 'fallback_image_style' => 'thumbnail', 'keyed_styles[responsive_image_test_module.mobile][1x][image_mapping_type]' => 'image_style', 'keyed_styles[responsive_image_test_module.mobile][1x][image_style]' => 'thumbnail', 'keyed_styles[responsive_image_test_module.narrow][1x][image_mapping_type]' => 'sizes', 'keyed_styles[responsive_image_test_module.narrow][1x][sizes]' => '(min-width: 700px) 700px, 100vw', 'keyed_styles[responsive_image_test_module.narrow][1x][sizes_image_styles][large]' => 'large', 'keyed_styles[responsive_image_test_module.narrow][1x][sizes_image_styles][medium]' => 'medium', 'keyed_styles[responsive_image_test_module.wide][1x][image_mapping_type]' => 'image_style', 'keyed_styles[responsive_image_test_module.wide][1x][image_style]' => 'large');
$this->drupalPostForm('admin/config/media/responsive-image-style/style_one', $edit, t('Save'));
$this->drupalGet('admin/config/media/responsive-image-style/style_one');
// Check the mapping for multipliers 1x and 2x for the mobile breakpoint.
$this->assertFieldByName('keyed_styles[responsive_image_test_module.mobile][1x][image_style]', 'thumbnail');
$this->assertFieldByName('keyed_styles[responsive_image_test_module.mobile][1x][image_mapping_type]', 'image_style');
$this->assertFieldByName('keyed_styles[responsive_image_test_module.mobile][2x][image_mapping_type]', '_none');
// Check the mapping for multipliers 1x and 2x for the narrow breakpoint.
$this->assertFieldByName('keyed_styles[responsive_image_test_module.narrow][1x][image_mapping_type]', 'sizes');
$this->assertFieldByName('keyed_styles[responsive_image_test_module.narrow][1x][sizes]', '(min-width: 700px) 700px, 100vw');
$this->assertFieldChecked('edit-keyed-styles-responsive-image-test-modulenarrow-1x-sizes-image-styles-large');
$this->assertFieldChecked('edit-keyed-styles-responsive-image-test-modulenarrow-1x-sizes-image-styles-medium');
$this->assertNoFieldChecked('edit-keyed-styles-responsive-image-test-modulenarrow-1x-sizes-image-styles-thumbnail');
$this->assertFieldByName('keyed_styles[responsive_image_test_module.narrow][2x][image_mapping_type]', '_none');
// Check the mapping for multipliers 1x and 2x for the wide breakpoint.
$this->assertFieldByName('keyed_styles[responsive_image_test_module.wide][1x][image_style]', 'large');
$this->assertFieldByName('keyed_styles[responsive_image_test_module.wide][1x][image_mapping_type]', 'image_style');
$this->assertFieldByName('keyed_styles[responsive_image_test_module.wide][2x][image_mapping_type]', '_none');
// Delete the style.
$this->drupalGet('admin/config/media/responsive-image-style/style_one/delete');
$this->drupalPostForm(NULL, array(), t('Delete'));
$this->drupalGet('admin/config/media/responsive-image-style');
$this->assertText('There is no Responsive image style yet.');
}
示例2: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state)
{
$config = $this->configFactory->get('youtube.settings');
$form['text'] = array('#type' => 'markup', '#markup' => '<p>' . t('The following settings will be used as default
values on all YouTube video fields. Many of these settings can be
overridden on a per-field basis.') . '</p>');
$form['youtube_global'] = array('#type' => 'fieldset', '#title' => t('Video parameters'));
$form['youtube_global']['youtube_suggest'] = array('#type' => 'checkbox', '#title' => t('Show suggested videos when the video finishes'), '#default_value' => $config->get('youtube_suggest'));
$form['youtube_global']['youtube_modestbranding'] = array('#type' => 'checkbox', '#title' => t('Do not show YouTube logo on video player control bar
(modestbranding).'), '#default_value' => $config->get('youtube_modestbranding'));
$form['youtube_global']['youtube_theme'] = array('#type' => 'checkbox', '#title' => t('Use a light colored control bar for video player controls
(theme).'), '#default_value' => $config->get('youtube_theme'));
$form['youtube_global']['youtube_color'] = array('#type' => 'checkbox', '#title' => t('Use a white colored video progress bar (color).'), '#default_value' => $config->get('youtube_color'), '#description' => t('Note: the modestbranding parameter will be ignored
when this is in use.'));
$form['youtube_global']['youtube_enablejsapi'] = array('#type' => 'checkbox', '#title' => t('Enable use of the IFrame API (enablejsapi, origin).'), '#default_value' => $config->get('youtube_enablejsapi'), '#description' => t('For more information on the IFrame API and how to use
it, see the <a href="@api_reference">IFrame API documentation</a>.', array('@api_reference' => 'https://developers.google.com/youtube/iframe_api_reference')));
$form['youtube_global']['youtube_wmode'] = array('#type' => 'checkbox', '#title' => t('Fix overlay problem on IE8 and lower'), '#default_value' => $config->get('youtube_wmode'), '#description' => t('Checking this will fix the issue of a YouTube video
showing above a modal window (including Drupal\'s Overlay). This is
needed if you have Overlay users in IE or have modal windows throughout
your site.'));
$form['youtube_thumbs'] = array('#type' => 'fieldset', '#title' => t('Thumbnails'));
$form['youtube_thumbs']['youtube_thumb_dir'] = array('#type' => 'textfield', '#title' => t('YouTube thumbnail directory'), '#field_prefix' => Settings::get('file_public_path', \Drupal::service('kernel')->getSitePath() . '/files') . '/', '#field_suffix' => '/thumbnail.jpg', '#description' => t('Location, within the files directory, where you would
like the YouTube thumbnails stored.'), '#default_value' => $config->get('youtube_thumb_dir'));
$form['youtube_thumbs']['youtube_thumb_hires'] = array('#type' => 'checkbox', '#title' => t('Save higher resolution thumbnail images'), '#description' => t('This will save thumbnails larger than the default
size, 480x360, to the thumbnails directory specified above.'), '#default_value' => $config->get('youtube_thumb_hires'));
$form['youtube_thumbs']['youtube_thumb_token_image_style'] = array('#type' => 'select', '#options' => image_style_options(TRUE), '#title' => t('Default token image style'), '#description' => t('Default image style for the output of a
youtube_image_url token.'), '#default_value' => $config->get('youtube_thumb_token_image_style'));
$form['youtube_thumbs']['youtube_thumb_delete_all'] = array('#type' => 'submit', '#value' => t('Refresh existing thumbnail image files'), '#submit' => array('youtube_thumb_delete_all'));
$form['youtube_privacy'] = array('#type' => 'checkbox', '#title' => t('Enable privacy-enhanced mode'), '#default_value' => $config->get('youtube_privacy'), '#description' => t('Checking this box will prevent YouTube from setting
cookies in your site visitors browser.'));
$form['youtube_player_class'] = array('#type' => 'textfield', '#title' => t('YouTube player class'), '#default_value' => $config->get('youtube_player_class'), '#description' => t('The iframe of every player will be given this class.
They will also be given IDs based off of this value.'));
return parent::buildForm($form, $form_state);
}
示例3: form
/**
* {@inheritdoc}
*/
public function form(array $form, FormStateInterface $form_state)
{
$form = parent::form($form, $form_state);
$entity = $this->entity;
$form['label'] = array('#type' => 'textfield', '#title' => 'Label', '#default_value' => $entity->label(), '#required' => TRUE);
$form['id'] = array('#type' => 'machine_name', '#default_value' => $entity->id(), '#required' => TRUE, '#machine_name' => array('exists' => [$this, 'exists'], 'replace_pattern' => '[^a-z0-9_.]+'));
$form['weight'] = array('#type' => 'weight', '#title' => 'Weight', '#default_value' => $entity->get('weight'));
$form['style'] = array('#type' => 'select', '#title' => 'Image style', '#options' => array(), '#default_value' => $entity->get('style'), '#access' => FALSE);
if ($this->moduleHandler->moduleExists('image')) {
$form['style']['#access'] = TRUE;
$form['style']['#options'] = image_style_options();
}
// The main premise of entity forms is that we get to work with an entity
// object at all times instead of checking submitted values from the form
// state.
$size = $entity->get('size');
$form['size_wrapper'] = array('#type' => 'container', '#attributes' => array('id' => 'size-wrapper'));
$form['size_wrapper']['size'] = array('#type' => 'select', '#title' => 'Size', '#options' => array('custom' => 'Custom'), '#empty_option' => '- None -', '#default_value' => $size, '#ajax' => array('callback' => '::updateSize', 'wrapper' => 'size-wrapper'));
$form['size_wrapper']['size_submit'] = array('#type' => 'submit', '#value' => t('Change size'), '#attributes' => array('class' => array('js-hide')), '#submit' => array(array(get_class($this), 'changeSize')));
$form['size_wrapper']['size_value'] = array('#type' => 'select', '#title' => 'Custom size value', '#options' => array('small' => 'Small', 'medium' => 'Medium', 'large' => 'Large'), '#default_value' => $entity->get('size_value'), '#access' => !empty($size));
$form['langcode'] = array('#type' => 'language_select', '#title' => t('Language'), '#languages' => LanguageInterface::STATE_ALL, '#default_value' => $entity->language()->getId());
$form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array('#type' => 'submit', '#value' => 'Save');
$form['actions']['delete'] = array('#type' => 'submit', '#value' => 'Delete');
return $form;
}
示例4: settingsSummary
/**
* {@inheritdoc}
*/
public function settingsSummary()
{
$summary = array();
$image_styles = image_style_options(FALSE);
// Unset possible 'No defined styles' option.
unset($image_styles['']);
// Styles could be lost because of enabled/disabled modules that defines
// their styles in code.
if (isset($image_styles[$this->getSetting('colorbox_node_style')])) {
$summary[] = t('Content image style: @style', array('@style' => $image_styles[$this->getSetting('colorbox_node_style')]));
} elseif ($this->getSetting('colorbox_node_style') == 'hide') {
$summary[] = t('Content image style: Hide');
} else {
$summary[] = t('Content image style: Original image');
}
if (isset($image_styles[$this->getSetting('colorbox_node_style_first')])) {
$summary[] = t('Content image style of first image: @style', array('@style' => $image_styles[$this->getSetting('colorbox_node_style_first')]));
}
if (isset($image_styles[$this->getSetting('colorbox_image_style')])) {
$summary[] = t('Colorbox image style: @style', array('@style' => $image_styles[$this->getSetting('colorbox_image_style')]));
} else {
$summary[] = t('Colorbox image style: Original image');
}
$gallery = array('post' => t('Per post gallery'), 'page' => t('Per page gallery'), 'field_post' => t('Per field in post gallery'), 'field_page' => t('Per field in page gallery'), 'custom' => t('Custom (with tokens)'), 'none' => t('No gallery'));
if ($this->getSetting('colorbox_gallery')) {
$summary[] = t('Colorbox gallery type: @type', array('@type' => $gallery[$this->getSetting('colorbox_gallery')])) . ($this->getSetting('colorbox_gallery') == 'custom' ? ' (' . $this->getSetting('colorbox_gallery_custom') . ')' : '');
}
$caption = array('auto' => t('Automatic'), 'title' => t('Title text'), 'alt' => t('Alt text'), 'entity_title' => t('Content title'), 'custom' => t('Custom (with tokens)'), 'none' => t('None'));
if ($this->getSetting('colorbox_caption')) {
$summary[] = t('Colorbox caption: @type', array('@type' => $caption[$this->getSetting('colorbox_caption')]));
}
return $summary;
}
示例5: settingsSummary
/**
* {@inheritdoc}
*/
public function settingsSummary()
{
$summary = [];
$image_styles = image_style_options(FALSE);
// Unset possible 'No defined styles' option.
unset($image_styles['']);
// Styles could be lost because of enabled/disabled modules that defines
// their styles in code.
$image_style_setting = $this->getSetting('first_image_style');
if (!isset($image_styles[$image_style_setting])) {
$image_styles[$image_style_setting] = t('Original image');
}
$summary[] = t('First image style: @style', ['@style' => $image_styles[$image_style_setting]]);
$image_style_setting = $this->getSetting('other_image_style');
if (!isset($image_styles[$image_style_setting])) {
$image_styles[$image_style_setting] = t('Original image');
}
$summary[] = t('Subsequent image style: @style', ['@style' => $image_styles[$image_style_setting]]);
$link_types = array('content' => t('Linked to content'), 'file' => t('Linked to file'));
// Display this setting only if image is linked.
$image_link_setting = $this->getSetting('image_link');
if (isset($link_types[$image_link_setting])) {
$summary[] = $link_types[$image_link_setting];
}
return $summary;
}
示例6: buildOptionsForm
/**
* Provide the options form.
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
// Link options.
$form['link_photo'] = array(
'#title' => t("Link image"),
'#description' => t("Link the image to the album page or image page."),
'#type' => 'radios',
'#options' => array(
'' => $this->t('None'),
'album' => $this->t('Album page'),
'image' => $this->t('Image page')
),
'#default_value' => $this->options['link_photo']
);
// Get image styles.
$style_options = image_style_options();
$form['image_style'] = array(
'#title' => $this->t('Image style'),
'#type' => 'select',
'#default_value' => $this->options['image_style'],
'#options' => $style_options,
);
parent::buildOptionsForm($form, $form_state);
}
示例7: form
/**
* Overrides Drupal\Core\Entity\EntityForm::form().
*
* @param array $form
* A nested array form elements comprising the form.
* @param \Drupal\Core\Form\FormStateInterface $form_state
* The current state of the form.
* @param \Drupal\responsive_image\ResponsiveImageMappingInterface $responsive_image_mapping
* The entity being edited.
*
* @return array
* The array containing the complete form.
*/
public function form(array $form, FormStateInterface $form_state)
{
if ($this->operation == 'duplicate') {
$form['#title'] = $this->t('<em>Duplicate responsive image mapping</em> @label', array('@label' => $this->entity->label()));
$this->entity = $this->entity->createDuplicate();
}
if ($this->operation == 'edit') {
$form['#title'] = $this->t('<em>Edit responsive image mapping</em> @label', array('@label' => $this->entity->label()));
}
/** @var \Drupal\responsive_image\ResponsiveImageMappingInterface $responsive_image_mapping */
$responsive_image_mapping = $this->entity;
$form['label'] = array('#type' => 'textfield', '#title' => $this->t('Label'), '#maxlength' => 255, '#default_value' => $responsive_image_mapping->label(), '#description' => $this->t("Example: 'Hero image' or 'Author image'."), '#required' => TRUE);
$form['id'] = array('#type' => 'machine_name', '#default_value' => $responsive_image_mapping->id(), '#machine_name' => array('exists' => '\\Drupal\\responsive_image\\Entity\\ResponsiveImageMapping::load', 'source' => array('label')), '#disabled' => (bool) $responsive_image_mapping->id() && $this->operation != 'duplicate');
if ((bool) $responsive_image_mapping->id() && $this->operation != 'duplicate') {
$description = $this->t('Select a breakpoint group from the enabled themes.') . ' ' . $this->t("Warning: if you change the breakpoint group you lose all your selected mappings.");
} else {
$description = $this->t('Select a breakpoint group from the enabled themes.');
}
$form['breakpointGroup'] = array('#type' => 'select', '#title' => $this->t('Breakpoint group'), '#default_value' => $responsive_image_mapping->getBreakpointGroup() != '' ? $responsive_image_mapping->getBreakpointGroup()->id() : '', '#options' => breakpoint_group_select_options(), '#required' => TRUE, '#description' => $description);
$image_styles = image_style_options(TRUE);
$image_styles[RESPONSIVE_IMAGE_EMPTY_IMAGE] = $this->t('- empty image -');
foreach ($responsive_image_mapping->getMappings() as $breakpoint_id => $mapping) {
foreach ($mapping as $multiplier => $image_style) {
$breakpoint = $responsive_image_mapping->getBreakpointGroup()->getBreakpointById($breakpoint_id);
$label = $multiplier . ' ' . $breakpoint->name . ' [' . $breakpoint->mediaQuery . ']';
$form['mappings'][$breakpoint_id][$multiplier] = array('#type' => 'select', '#title' => String::checkPlain($label), '#options' => $image_styles, '#default_value' => $image_style, '#description' => $this->t('Select an image style for this breakpoint.'));
}
}
$form['#tree'] = TRUE;
return parent::form($form, $form_state, $responsive_image_mapping);
}
示例8: settingsForm
/**
* {@inheritdoc}
*/
public function settingsForm(array $form, FormStateInterface $form_state)
{
$element = parent::settingsForm($form, $form_state);
$element['image_style'] = ['#title' => $this->t('Image Style'), '#type' => 'select', '#default_value' => $this->getSetting('image_style'), '#required' => FALSE, '#options' => image_style_options()];
$element['link_image_to'] = ['#title' => $this->t('Link image to'), '#type' => 'select', '#empty_option' => $this->t('- None -'), '#default_value' => $this->getSetting('link_image_to'), '#options' => [static::LINK_CONTENT => $this->t('Content'), static::LINK_PROVIDER => $this->t('Provider URL')]];
return $element;
}
示例9: getReplacementOptions
/**
* Returns a list of image style replacement options.
*
* @return array
* An option list suitable for the form select '#options'.
*/
protected function getReplacementOptions()
{
if (!isset($this->replacementOptions)) {
$this->replacementOptions = array_diff_key(image_style_options(), [$this->getEntity()->id() => '']);
}
return $this->replacementOptions;
}
示例10: settingsForm
/**
* {@inheritdoc}
*/
public function settingsForm(array $form, FormStateInterface $form_state)
{
$elements = parent::settingsForm($form, $form_state);
$elements['image_style'] = array('#type' => 'select', '#title' => t('Image style'), '#options' => image_style_options(FALSE), '#default_value' => $this->getSetting('image_style'), '#empty_option' => t('None (original image)'));
$link_types = array('content' => t('Content'), 'youtube' => t('YouTube'));
$elements['image_link'] = array('#title' => t('Link image to'), '#type' => 'select', '#default_value' => $this->getSetting('image_link'), '#empty_option' => t('Nothing'), '#options' => $link_types);
return $elements;
}
示例11: settingsSummary
/**
* {@inheritdoc}
*/
public function settingsSummary()
{
$image_styles = image_style_options(FALSE);
$thumb_image_style = $this->getSetting('thumbnail_image_style');
$popup_image_style = $this->getSetting('popup_image_style');
// Check image styles exist or display 'Original Image'.
$summary[] = t('Thumbnail image style: @thumb_style. Popup image style: @popup_style', ['@thumb_style' => isset($image_styles[$thumb_image_style]) ? $thumb_image_style : 'Original Image', '@popup_style' => isset($image_styles[$popup_image_style]) ? $popup_image_style : 'Original Image']);
return $summary;
}
示例12: testNumericStyleName
/**
* Test creating an image style with a numeric name and ensuring it can be
* applied to an image.
*/
function testNumericStyleName()
{
$style_name = rand();
$style_label = $this->randomString();
$edit = array('name' => $style_name, 'label' => $style_label);
$this->drupalPostForm('admin/config/media/image-styles/add', $edit, t('Create new style'));
$this->assertRaw(t('Style %name was created.', array('%name' => $style_label)));
$options = image_style_options();
$this->assertTrue(array_key_exists($style_name, $options), format_string('Array key %key exists.', array('%key' => $style_name)));
}
示例13: buildForm
/**
* {inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state)
{
$form['#form_horizontal'] = true;
$form['interface'] = ['#type' => 'fieldset', '#title' => $this->t("User interface")];
$form['interface'][APB_VAR_USER_PAGER_LIMIT] = ['#type' => 'select', '#title' => $this->t("User notification page limit"), '#options' => drupal_map_assoc([5, 10, 20, 30, 50, 100]), '#description' => $this->t("Number of notifications being displayed per page in user notification page."), '#default_value' => variable_get(APB_VAR_USER_PAGER_LIMIT, APB_DEF_USER_PAGER_LIMIT)];
$form['interface'][APB_VAR_USER_BLOCK_LIMIT] = ['#type' => 'select', '#title' => $this->t("User notification block limit"), '#options' => drupal_map_assoc([3, 5, 8, 10, 13, 15, 20]), '#description' => $this->t("Number of notifications being displayed per in the user notification block."), '#default_value' => variable_get(APB_VAR_USER_BLOCK_LIMIT, APB_DEF_USER_BLOCK_LIMIT)];
$form['interface'][APB_VAR_IMG_STYLE] = ['#type' => 'select', '#title' => $this->t("Notification image style"), '#empty_option' => $this->t("Do not display image"), '#options' => image_style_options(true), '#description' => $this->t("Number of notifications being displayed per page in user notification page."), '#default_value' => variable_get(APB_VAR_IMG_STYLE, APB_DEF_IMG_STYLE)];
$form['advanced'] = ['#type' => 'fieldset', '#title' => $this->t("Advanced / Performance")];
$form['advanced'][APB_VAR_ENABLE_PROD] = ['#type' => 'checkbox', '#title' => $this->t("Enable production mode"), '#description' => $this->t("Will suppress some warnings, errors and exceptions. Always check this option on a production site."), '#default_value' => variable_get(APB_VAR_ENABLE_PROD, APB_DEF_ENABLE_PROD)];
$form['advanced'][APB_VAR_ENABLE_FORMATTED_CONTENT] = ['#type' => 'checkbox', '#title' => $this->t("Store content inside messages"), '#description' => $this->t("If checked, formatted messages will be sent in the message contents instead of being formatted at view time. This will bypass translation but allows you to display those notifications outside of the originating website. If checked generated links inside formatted notifications will all be absolute. Note that if you change this setting and data has already been sent some notifications might not be displayed correctly."), '#default_value' => variable_get(APB_VAR_ENABLE_FORMATTED_CONTENT, APB_DEF_ENABLE_FORMATTED_CONTENT)];
return system_settings_form($form);
}
示例14: form
/**
* Overrides Drupal\Core\Entity\EntityForm::form().
*
* @param array $form
* A nested array form elements comprising the form.
* @param \Drupal\Core\Form\FormStateInterface $form_state
* The current state of the form.
*
* @return array
* The array containing the complete form.
*/
public function form(array $form, FormStateInterface $form_state)
{
if ($this->operation == 'duplicate') {
$form['#title'] = $this->t('<em>Duplicate responsive image style</em> @label', array('@label' => $this->entity->label()));
$this->entity = $this->entity->createDuplicate();
}
if ($this->operation == 'edit') {
$form['#title'] = $this->t('<em>Edit responsive image style</em> @label', array('@label' => $this->entity->label()));
}
/** @var \Drupal\responsive_image\ResponsiveImageStyleInterface $responsive_image_style */
$responsive_image_style = $this->entity;
$form['label'] = array('#type' => 'textfield', '#title' => $this->t('Label'), '#maxlength' => 255, '#default_value' => $responsive_image_style->label(), '#description' => $this->t("Example: 'Hero image' or 'Author image'."), '#required' => TRUE);
$form['id'] = array('#type' => 'machine_name', '#default_value' => $responsive_image_style->id(), '#machine_name' => array('exists' => '\\Drupal\\responsive_image\\Entity\\ResponsiveImageStyle::load', 'source' => array('label')), '#disabled' => (bool) $responsive_image_style->id() && $this->operation != 'duplicate');
$image_styles = image_style_options(TRUE);
$image_styles[RESPONSIVE_IMAGE_ORIGINAL_IMAGE] = $this->t('- None (original image) -');
$image_styles[RESPONSIVE_IMAGE_EMPTY_IMAGE] = $this->t('- empty image -');
if ((bool) $responsive_image_style->id() && $this->operation != 'duplicate') {
$description = $this->t('Select a breakpoint group from the installed themes and modules. Below you can select which breakpoints to use from this group. You can also select which image style or styles to use for each breakpoint you use.') . ' ' . $this->t("Warning: if you change the breakpoint group you lose all your image style selections for each breakpoint.");
} else {
$description = $this->t('Select a breakpoint group from the installed themes and modules.');
}
$form['breakpoint_group'] = array('#type' => 'select', '#title' => $this->t('Breakpoint group'), '#default_value' => $responsive_image_style->getBreakpointGroup() ?: 'responsive_image', '#options' => $this->breakpointManager->getGroups(), '#required' => TRUE, '#description' => $description, '#ajax' => array('callback' => '::breakpointMappingFormAjax', 'wrapper' => 'responsive-image-style-breakpoints-wrapper'));
$form['keyed_styles'] = array('#type' => 'container', '#attributes' => array('id' => 'responsive-image-style-breakpoints-wrapper'));
// By default, breakpoints are ordered from smallest weight to largest:
// the smallest weight is expected to have the smallest breakpoint width,
// while the largest weight is expected to have the largest breakpoint
// width. For responsive images, we need largest breakpoint widths first, so
// we need to reverse the order of these breakpoints.
$breakpoints = array_reverse($this->breakpointManager->getBreakpointsByGroup($responsive_image_style->getBreakpointGroup()));
foreach ($breakpoints as $breakpoint_id => $breakpoint) {
foreach ($breakpoint->getMultipliers() as $multiplier) {
$label = $multiplier . ' ' . $breakpoint->getLabel() . ' [' . $breakpoint->getMediaQuery() . ']';
$form['keyed_styles'][$breakpoint_id][$multiplier] = array('#type' => 'details', '#title' => $label);
$image_style_mapping = $responsive_image_style->getImageStyleMapping($breakpoint_id, $multiplier);
if (\Drupal::moduleHandler()->moduleExists('help')) {
$description = $this->t('See the <a href=":responsive_image_help">Responsive Image help page</a> for information on the sizes attribute.', array(':responsive_image_help' => \Drupal::url('help.page', array('name' => 'responsive_image'))));
} else {
$description = $this->t('Enable the Help module for more information on the sizes attribute.');
}
$form['keyed_styles'][$breakpoint_id][$multiplier]['image_mapping_type'] = array('#title' => $this->t('Type'), '#type' => 'radios', '#options' => array('sizes' => $this->t('Select multiple image styles and use the sizes attribute.'), 'image_style' => $this->t('Select a single image style.'), '_none' => $this->t('Do not use this breakpoint.')), '#default_value' => isset($image_style_mapping['image_mapping_type']) ? $image_style_mapping['image_mapping_type'] : '_none', '#description' => $description);
$form['keyed_styles'][$breakpoint_id][$multiplier]['image_style'] = array('#type' => 'select', '#title' => $this->t('Image style'), '#options' => $image_styles, '#default_value' => isset($image_style_mapping['image_mapping']) && is_string($image_style_mapping['image_mapping']) ? $image_style_mapping['image_mapping'] : '', '#description' => $this->t('Select an image style for this breakpoint.'), '#states' => array('visible' => array(':input[name="keyed_styles[' . $breakpoint_id . '][' . $multiplier . '][image_mapping_type]"]' => array('value' => 'image_style'))));
$form['keyed_styles'][$breakpoint_id][$multiplier]['sizes'] = array('#type' => 'textfield', '#title' => $this->t('Sizes'), '#default_value' => isset($image_style_mapping['image_mapping']['sizes']) ? $image_style_mapping['image_mapping']['sizes'] : '100vw', '#description' => $this->t('Enter the value for the sizes attribute, for example: %example_sizes.', ['%example_sizes' => '(min-width:700px) 700px, 100vw']), '#states' => array('visible' => array(':input[name="keyed_styles[' . $breakpoint_id . '][' . $multiplier . '][image_mapping_type]"]' => array('value' => 'sizes')), 'required' => array(':input[name="keyed_styles[' . $breakpoint_id . '][' . $multiplier . '][image_mapping_type]"]' => array('value' => 'sizes'))));
$form['keyed_styles'][$breakpoint_id][$multiplier]['sizes_image_styles'] = array('#title' => $this->t('Image styles'), '#type' => 'checkboxes', '#options' => array_diff_key($image_styles, array('' => '')), '#description' => $this->t('Select image styles with widths that range from the smallest amount of space this image will take up in the layout to the largest, bearing in mind that high resolution screens will need images 1.5x to 2x larger.'), '#default_value' => isset($image_style_mapping['image_mapping']['sizes_image_styles']) ? $image_style_mapping['image_mapping']['sizes_image_styles'] : array(), '#states' => array('visible' => array(':input[name="keyed_styles[' . $breakpoint_id . '][' . $multiplier . '][image_mapping_type]"]' => array('value' => 'sizes')), 'required' => array(':input[name="keyed_styles[' . $breakpoint_id . '][' . $multiplier . '][image_mapping_type]"]' => array('value' => 'sizes'))));
// Expand the details if "do not use this breakpoint" was not selected.
if ($form['keyed_styles'][$breakpoint_id][$multiplier]['image_mapping_type']['#default_value'] != '_none') {
$form['keyed_styles'][$breakpoint_id][$multiplier]['#open'] = TRUE;
}
}
}
$form['fallback_image_style'] = array('#title' => $this->t('Fallback image style'), '#type' => 'select', '#default_value' => $responsive_image_style->getFallbackImageStyle(), '#options' => $image_styles, '#required' => TRUE, '#description' => t('Select the smallest image style you expect to appear in this space. The fallback image style should only appear on the site if an error occurs.'));
$form['#tree'] = TRUE;
return parent::form($form, $form_state, $responsive_image_style);
}
示例15: settingsForm
/**
* {@inheritdoc}
*/
public function settingsForm(array $form, FormStateInterface $form_state)
{
$image_styles = image_style_options(FALSE);
$description_link = Link::fromTextAndUrl($this->t('Configure Image Styles'), Url::fromRoute('entity.image_style.collection'));
$element['image_style'] = ['#title' => t('Image style'), '#type' => 'select', '#default_value' => $this->getSetting('image_style'), '#empty_option' => t('None (original image)'), '#options' => $image_styles, '#description' => $description_link->toRenderable() + ['#access' => $this->currentUser->hasPermission('administer image styles')]];
$link_types = array('content' => t('Content'), 'file' => t('File'));
$element['image_link'] = array('#title' => t('Link image to'), '#type' => 'select', '#default_value' => $this->getSetting('image_link'), '#empty_option' => t('Nothing'), '#options' => $link_types);
$element['items'] = array('#type' => 'number', '#title' => $this->t('Items'), '#description' => $this->t('Maximum amount of items displayed at a time with the widest browser width.'), '#default_value' => $this->getSetting('items'));
$element['itemsDesktop'] = array('#type' => 'textfield', '#title' => $this->t('Items Desktop'), '#description' => $this->t('This allows you to preset the number of slides visible with a particular browser width. The format is [x,y] whereby x=browser width and y=number of slides displayed. For example [1199,4] means that if(window<=1199){ show 4 slides per page}'), '#default_value' => $this->getSetting('itemsDesktop'));
$element['itemsDesktopSmall'] = array('#type' => 'textfield', '#title' => $this->t('Items Desktop Small'), '#description' => $this->t('Example: [979,3]'), '#default_value' => $this->getSetting('itemsDesktopSmall'));
$element['itemsTablet'] = array('#type' => 'textfield', '#title' => $this->t('Items Tablet'), '#description' => $this->t('Example: [768,2]'), '#default_value' => $this->getSetting('itemsTablet'));
$element['itemsMobile'] = array('#type' => 'textfield', '#title' => $this->t('Items Mobile'), '#description' => $this->t('Example: [479,1]'), '#default_value' => $this->getSetting('itemsMobile'));
$element['singleItem'] = array('#type' => 'checkbox', '#title' => $this->t('Single Item'), '#default_value' => $this->getSetting('singleItem'), '#description' => $this->t('Display only one item.'));
//itemsScaleUp
$element['itemsScaleUp'] = array('#type' => 'checkbox', '#title' => $this->t('Items ScaleUp'), '#default_value' => $this->getSetting('itemsScaleUp'), '#description' => $this->t('Option to not stretch items when it is less than the supplied items.'));
//slideSpeed
$element['slideSpeed'] = array('#type' => 'number', '#title' => $this->t('Slide Speed'), '#default_value' => $this->getSetting('slideSpeed'), '#description' => $this->t('Slide speed in milliseconds.'));
//paginationSpeed
$element['paginationSpeed'] = array('#type' => 'number', '#title' => $this->t('Pagination Speed'), '#default_value' => $this->getSetting('paginationSpeed'), '#description' => $this->t('Pagination speed in milliseconds.'));
//rewindSpeed
$element['rewindSpeed'] = array('#type' => 'number', '#title' => $this->t('Rewind Speed'), '#default_value' => $this->getSetting('rewindSpeed'), '#description' => $this->t('Rewind speed in milliseconds.'));
//autoPlay
$element['autoPlay'] = array('#type' => 'checkbox', '#title' => $this->t('AutoPlay'), '#default_value' => $this->getSetting('autoPlay'));
//stopOnHover
$element['stopOnHover'] = array('#type' => 'checkbox', '#title' => $this->t('Stop On Hover'), '#default_value' => $this->getSetting('stopOnHover'), '#description' => $this->t('Stop autoplay on mouse hover.'));
//navigation
$element['navigation'] = array('#type' => 'checkbox', '#title' => $this->t('Navigation'), '#default_value' => $this->getSetting('navigation'), '#description' => $this->t('Display "next" and "prev" buttons.'));
//prevText
$element['prevText'] = array('#type' => 'textfield', '#title' => $this->t('Prev Text'), '#default_value' => $this->getSetting('prevText'), '#description' => $this->t('Text for navigation prev button'));
//nextText
$element['nextText'] = array('#type' => 'textfield', '#title' => $this->t('Next Text'), '#default_value' => $this->getSetting('nextText'), '#description' => $this->t('Text for navigation next button'));
//rewindNav
$element['rewindNav'] = array('#type' => 'checkbox', '#title' => $this->t('Rewind Nav'), '#default_value' => $this->getSetting('rewindNav'), '#description' => $this->t('Slide to first item.'));
//scrollPerPage
$element['scrollPerPage'] = array('#type' => 'checkbox', '#title' => $this->t('Scroll Per Page'), '#default_value' => $this->getSetting('scrollPerPage'), '#description' => $this->t('Scroll per page not per item. This affect next/prev buttons and mouse/touch dragging.'));
//pagination
$element['pagination'] = array('#type' => 'checkbox', '#title' => $this->t('pagination'), '#default_value' => $this->getSetting('pagination'), '#description' => $this->t('Show pagination.'));
//paginationNumbers
$element['paginationNumbers'] = array('#type' => 'checkbox', '#title' => $this->t('Pagination Numbers'), '#default_value' => $this->getSetting('paginationNumbers'), '#description' => $this->t('Show numbers inside pagination buttons.'));
//responsive
$element['responsive'] = array('#type' => 'checkbox', '#title' => $this->t('Responsive'), '#default_value' => $this->getSetting('responsive'), '#description' => $this->t('Uncheck to use Owl Carousel on desktop-only.'));
//responsiveRefreshRate
$element['responsiveRefreshRate'] = array('#type' => 'number', '#title' => $this->t('Responsive Refresh Rate'), '#default_value' => $this->getSetting('responsiveRefreshRate'), '#description' => $this->t('Check window width changes every 200ms for responsive actions.'));
//mouseDrag
$element['mouseDrag'] = array('#type' => 'checkbox', '#title' => $this->t('Mouse Drag'), '#default_value' => $this->getSetting('mouseDrag'), '#description' => $this->t('Turn off/on mouse events.'));
//touchDrag
$element['touchDrag'] = array('#type' => 'checkbox', '#title' => $this->t('Touch Drag'), '#default_value' => $this->getSetting('touchDrag'), '#description' => $this->t('Turn off/on touch events.'));
//transitionStyle
$element['transitionStyle'] = array('#type' => 'select', '#options' => array('fade' => $this->t('Fade'), 'backSlide' => $this->t('Back Slide'), 'goDown' => $this->t('Go Down'), 'scaleUp' => $this->t('ScaleUp')), '#title' => $this->t('Transition Style'), '#default_value' => $this->getSetting('transitionStyle'), '#description' => $this->t('Add CSS3 transition style. Works only with one item on screen.'));
return $element + parent::settingsForm($form, $form_state);
}