regionhalland/region-halland-plugin-acf-site-settings-image-link-repeater

Skapa en bild-lista inklusive länk för att användas i ex footer

v1.2.0 2020-11-04 15:58 UTC

This package is auto-updated.

Last update: 2024-12-05 00:38:29 UTC


README

Hur man använder Region Hallands plugin "RhAcfSiteSettingsImageLinkRepeater"

Nedan följer instruktioner hur du kan använda pluginet "RhAcfSiteSettingsImageLinkRepeater".

Användningsområde

Denna plugin skapar skapar repeterande fält i admin med bild + länk

Licensmodell

Denna plugin använder licensmodell GPL-3.0. Du kan läsa mer om denna licensmodell via den medföljande filen:

LICENSE (https://regionhalland.visualstudio.com/public.RhWpPlugIns/_git/RhAcfSiteSettingsImageLinkRepeater?path=%2FLICENSE&version=GBmaster)

Installation och aktivering

A) Hämta pluginen via Git eller läs in det med Composer
B) Installera Region Hallands plugin i Wordpress plugin folder
C) Aktivera pluginet inifrån Wordpress admin

Hämta hem pluginet via Git

git clone https://regionhalland.visualstudio.com/public.RhWpPlugIns/_git/RhAcfSiteSettingsImageLinkRepeater

Läs in pluginen via composer

Dessa två delar behöver du lägga in i din composer-fil

Repositories = var pluginen är lagrad, i detta fall på github

"repositories": [
  {
    "type": "vcs",
    "url": "https://regionhalland.visualstudio.com/public.RhWpPlugIns/_git/RhAcfSiteSettingsImageLinkRepeater"
  },
],

Require = anger vilken version av pluginen du vill använda, i detta fall version 1.0.0

OBS! Justera så att du hämtar aktuell version.

"require": {
  "regionhalland/region-halland-plugin-acf-site-settings-image-link-repeater": "1.0.0"
},

Loopa ut bilderna inkl länk via "Blade"

@if(function_exists('get_region_halland_acf_site_settings_image_link_repeater_list'))
  @php($myImages = get_region_halland_acf_site_settings_image_link_repeater_list())
  @if($myImages['number_of_images'] > 0)
    @foreach ($myImages['images'] as $image)
      @if ($image['has-image-link'] == 1)
        <a href="{{ $image['image-link-url'] }}" target="{{ $image['image-link-target'] }}"><img src="{{ $image['image-url'] }}" width="{{ $image['image-width'] }}" height="{{ $image['image-height'] }}"></a>
      @else
        <img src="{{ $image['image-url'] }}" width="{{ $image['image-width'] }}" height="{{ $image['image-height'] }}">
      @endif
    @endforeach
  @endif
@endif

Exempel på hur arrayen kan se ut

array (size=2)
  'number_of_images' => int 6
  'images' => 
    array (size=6)
      0 => 
        array (size=7)
          'image-url' => string 'http://dev-template.local/app/uploads/2020/04/sol-a-73x70.jpg' (length=61)
          'image-width' => int 73
          'image-height' => int 70
          'image-alt' => string '' (length=0)
          'image-caption' => string '' (length=0)
          'has-image-link' => int 1
          'image-link-title' => string 'Puff C' (length=6)
          'image-link-url' => string 'http://dev-template.local/puffar/puff-c/' (length=40)
          'image-link-target' => string '' (length=0)
      1 => 
        array (size=7)
          'image-url' => string 'http://dev-template.local/app/uploads/2020/04/sol-b-64x70.jpg' (length=61)
          'image-width' => int 64
          'image-height' => int 70
          'image-alt' => string '' (length=0)
          'image-caption' => string '' (length=0)
          'has-image-link' => int 1
          'image-link-title' => string 'Puff B' (length=6)
          'image-link-url' => string 'http://dev-template.local/puffar/puff-b/' (length=40)
          'image-link-target' => string '' (length=0)
      2 => 
        array (size=7)
          'image-url' => string 'http://dev-template.local/app/uploads/2020/04/sol-c-75x70.jpg' (length=61)
          'image-width' => int 75
          'image-height' => int 70
          'image-alt' => string '' (length=0)
          'image-caption' => string '' (length=0)
          'has-image-link' => int 1
          'image-link-title' => string 'Puff A' (length=6)
          'image-link-url' => string 'http://dev-template.local/puffar/puff-a/' (length=40)
          'image-link-target' => string '_blank' (length=6)
      3 => 
        array (size=7)
          'image-url' => string 'http://dev-template.local/app/uploads/2020/04/sol-d-70x70.jpg' (length=61)
          'image-width' => int 70
          'image-height' => int 70
          'image-alt' => string '' (length=0)
          'image-caption' => string '' (length=0)
          'has-image-link' => int 1
          'image-link-title' => string 'Extrainfo 1' (length=11)
          'image-link-url' => string 'http://dev-template.local/extrainfo/extrainfo-1/' (length=48)
          'image-link-target' => string '' (length=0)
      4 => 
        array (size=7)
          'image-url' => string 'http://dev-template.local/app/uploads/2020/04/sol-e-70x70.png' (length=61)
          'image-width' => int 70
          'image-height' => int 70
          'image-alt' => string '' (length=0)
          'image-caption' => string '' (length=0)
          'has-image-link' => int 1
          'image-link-title' => string 'Extrainfo 2' (length=11)
          'image-link-url' => string 'http://dev-template.local/extrainfo/extrainfo-2/' (length=48)
          'image-link-target' => string '' (length=0)
      5 => 
        array (size=7)
          'image-url' => string 'http://dev-template.local/app/uploads/2020/04/sol-f-64x70.jpg' (length=61)
          'image-width' => int 64
          'image-height' => int 70
          'image-alt' => string '' (length=0)
          'image-caption' => string '' (length=0)
          'has-image-link' => int 1
          'image-link-title' => string 'Extrainfo 3' (length=11)
          'image-link-url' => string 'http://dev-template.local/extrainfo/extrainfo-3/' (length=48)
          'image-link-target' => string '_blank' (length=6)

Versionhistorik

1.3.0

  • ACF fälten visas nu i WP-JSON REST APIet

1.2.0

  • Lagt till alt + caption text på bilderna

1.1.1

  • Hoppa över tillagda fält som inte valts

1.1.0

  • Lagt till en kontroll om det finns några image links

1.0.0

  • Första version