Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
deleted 29 characters in body
Source Link
Mojtaba Reyhani
  • 2.1k
  • 8
  • 35
  • 67

I intend to create a slideshow in front page of my theme to show all images in custom directory, I try to use file_scan_directory and drupal_get_path in below codes to get any non static images path and display that images automatically without any need to calling each one of them separately:
Theme Name.theme:

function MyThemeName_preprocess_page(&$variables) {
$mask = '/\.(?:jp[e]?g|gif|png)$/i';
$files = file_scan_directory(drupal_get_path('theme', 'Theme Name') . '/assets/img/orbit', $mask);
ksort($files);
$variables['files'] = $files;
}

page.html.twig:

<div class="slideshow">
{% for file in files %}
<img src="{{ file.uri }}" width="100%" height="100%" alt="{{ file.name }}"/>
{% endfor %}

I would be happy to hear what is the problem with the codes and what is the right way to load that slideshowe pictures?

I intend to create a slideshow in front page of my theme to show all images in custom directory, I try to use file_scan_directory and drupal_get_path in below codes to get any non static images path and display that images automatically without any need to calling each one of them separately:
Theme Name.theme:

$mask = '/\.(?:jp[e]?g|gif|png)$/i';
$files = file_scan_directory(drupal_get_path('theme', 'Theme Name') . '/assets/img/orbit', $mask);
ksort($files);
$variables['files'] = $files;

page.html.twig:

<div class="slideshow">
{% for file in files %}
<img src="{{ file.uri }}" width="100%" height="100%" alt="{{ file.name }}"/>
{% endfor %}

I would be happy to hear what is the problem with the codes and what is the right way to load that slideshowe pictures?

I intend to create a slideshow in front page of my theme to show all images in custom directory, I try to use file_scan_directory and drupal_get_path in below codes to get any non static images path and display that images automatically without any need to calling each one of them separately:
Theme Name.theme:

function MyThemeName_preprocess_page(&$variables) {
$mask = '/\.(?:jp[e]?g|gif|png)$/i';
$files = file_scan_directory(drupal_get_path('theme', 'Theme Name') . '/assets/img/orbit', $mask);
ksort($files);
$variables['files'] = $files;
}

page.html.twig:

{% for file in files %}
<img src="{{ file.uri }}" width="100%" height="100%" alt="{{ file.name }}"/>
{% endfor %}

I would be happy to hear what is the problem with the codes and what is the right way to load that slideshowe pictures?

added 132 characters in body
Source Link
Mojtaba Reyhani
  • 2.1k
  • 8
  • 35
  • 67

I intend to create a slideshow in front page of my theme to show all images in custom directory, I try to use file_scan_directory and drupal_get_path in below codes to get any non static images path and display that images automatically without any need to calling each one of them separately:
Theme Name.theme:

$mask = '/\.(?:jp[e]?g|gif|png)$/i';
$files = file_scan_directory(drupal_get_path('theme', 'Theme Name') . '/assets/img/orbit', $mask);
ksort($files);
$variables['files'] = $files;

page.html.twig:

<div class="slideshow">
{% for file in files %}
<img src="{{ file.uri }}" width="100%" height="100%" alt="{{ file.name }}"/>
{% endfor %}

I would be happy to hear what is the problem with the codes and what is the right way to load that slideshowe pictures?

I intend to create a slideshow in front page of my theme to show all images in custom directory, I try to use below codes to get any non static images path and display that images automatically without any need to calling each one of them separately:
Theme Name.theme:

$mask = '/\.(?:jp[e]?g|gif|png)$/i';
$files = file_scan_directory(drupal_get_path('theme', 'Theme Name') . '/assets/img/orbit', $mask);
ksort($files);
$variables['files'] = $files;

page.html.twig:

<div class="slideshow">
{% for file in files %}
<img src="{{ file.uri }}" width="100%" height="100%" alt="{{ file.name }}"/>
{% endfor %}

I would be happy to hear what is the problem with the codes and what is the right way to load that slideshowe pictures?

I intend to create a slideshow in front page of my theme to show all images in custom directory, I try to use file_scan_directory and drupal_get_path in below codes to get any non static images path and display that images automatically without any need to calling each one of them separately:
Theme Name.theme:

$mask = '/\.(?:jp[e]?g|gif|png)$/i';
$files = file_scan_directory(drupal_get_path('theme', 'Theme Name') . '/assets/img/orbit', $mask);
ksort($files);
$variables['files'] = $files;

page.html.twig:

<div class="slideshow">
{% for file in files %}
<img src="{{ file.uri }}" width="100%" height="100%" alt="{{ file.name }}"/>
{% endfor %}

I would be happy to hear what is the problem with the codes and what is the right way to load that slideshowe pictures?

added 7 characters in body
Source Link
Mojtaba Reyhani
  • 2.1k
  • 8
  • 35
  • 67

I intend to create a slideshow in front page of my theme to show all images in custom directory, I try to use below codes to get any non static images path and display that images automatically without any need to calling each one of them separately:
Theme Name.theme:

$mask = '/\.(?:jp[e]?g|gif|png)$/i';
$files = file_scan_directory(drupal_get_path('theme', 'Theme Name') . '/assets/img/orbit', $mask);
ksort($files);
$variables['files'] = $files;

page.html.twig:

<div class="slideshow">
{% for file in files %}
<img src="{{ file.uri }}" width="100%" height="100%" alt="{{ file.name }}"/>
{% endfor %}

I would be happy to hear what is the problem with the codes and what is the right way to load that slideshowe pictures?

I intend to create a slideshow in front page of my theme to show all images in custom directory, I try to use below codes to get any non static images path:
Theme Name.theme:

$mask = '/\.(?:jp[e]?g|gif|png)$/i';
$files = file_scan_directory(drupal_get_path('theme', 'Theme Name') . '/assets/img/orbit', $mask);
ksort($files);
$variables['files'] = $files;

page.html.twig:

<div class="slideshow">
{% for file in files %}
<img src="{{ file.uri }}" width="100%" height="100%" alt="{{ file.name }}"/>
{% endfor %}

I would be happy to hear what is the problem with the codes and what is the right way to load that slideshowe pictures?

I intend to create a slideshow in front page of my theme to show all images in custom directory, I try to use below codes to get any non static images path and display that images automatically without any need to calling each one of them separately:
Theme Name.theme:

$mask = '/\.(?:jp[e]?g|gif|png)$/i';
$files = file_scan_directory(drupal_get_path('theme', 'Theme Name') . '/assets/img/orbit', $mask);
ksort($files);
$variables['files'] = $files;

page.html.twig:

<div class="slideshow">
{% for file in files %}
<img src="{{ file.uri }}" width="100%" height="100%" alt="{{ file.name }}"/>
{% endfor %}

I would be happy to hear what is the problem with the codes and what is the right way to load that slideshowe pictures?

added 7 characters in body
Source Link
Mojtaba Reyhani
  • 2.1k
  • 8
  • 35
  • 67
Loading
added 4 characters in body
Source Link
Mojtaba Reyhani
  • 2.1k
  • 8
  • 35
  • 67
Loading
edited title
Link
Mojtaba Reyhani
  • 2.1k
  • 8
  • 35
  • 67
Loading
added 44 characters in body
Source Link
Mojtaba Reyhani
  • 2.1k
  • 8
  • 35
  • 67
Loading
edited title
Link
Mojtaba Reyhani
  • 2.1k
  • 8
  • 35
  • 67
Loading