Visual file select panel field extension

@lekkerduidelijk:

I honestly don’t know which is faster.
However the two examples (mine and yours) apply to a little bit different use-cases:

  • In your example, you convert every file to a single file object to use it within the loop. This is fine, if the order the Selector field stores the filenames doesn’t matter or fits your needs.
  • In my example, I create a file collection object out of all selected files which you can filter/sort/search further (just like you can do with $page->files() ). In most cases, this might not be needed, but I though I provide a “one fits all” solution.

Your way of using the Selector field value is completely fine, though!

Hey,

I try to post a Image but it doesn’t work :frowning:

My Blueprint:

<?php if(!defined('KIRBY')) exit ?>

title: Site
pages: true
fields:
  	title:
    	label: Title
    	type:  text
	intro:
		label: Intro Image
		type:  selector
		mode:  single
		types:
		  - image

I have tried some of the solutions above without a result.
If someone can help me and post a code with html tags I’d very thankful !!

Hi @Andi,

please try to use the following code snippet where you want to use the intro image and let me know if it works!


<?php

    // Convert the selected filename to a full file object
    $filename = $page->intro();
    $intro = $page->files()->find($filename);

?>

<!-- Use the file object -->
<img src="<?php echo $intro->url(); ?>" />

Hi Jonas,

I tried your Code but nothing happens.
My HTML is empty at the point where I use your snippet.

<section class="intro" id="intro">
<h1 class="headline--big"><?php echo $data->headline()->html() ?></h1>
<h2 class="subheadline"><?php echo $data->subheadline()->html() ?></h2>
<?php
    // Convert the selected filename to a full file object
    $filename = $page->intro();
    $intro = $page->files()->find($filename);
?>
<!-- Use the file object -->
<img src="<?php echo $intro->url(); ?>" />

and the output:

<section class="intro" id="intro">
	<h1 class="headline--big">Überschrift</h1>
	<h2 class="subheadline">unterschrift</h2>
	<!-- Use the file object -->
<img src="

Shouldn’t it read “$data” instead of “$page” in this code snippet?

$filename = $data->intro();
$intro = $data->files()->find($filename);

Yeah, I don’t know why @Andi doesn’t use the $page variable in his code (probably some one-page layout stuff), but of course, the snippet I posted should be adapted accordingly.

<section class="intro" id="intro">
    <h1 class="headline--big"><?php echo $data->headline()->html() ?></h1>
    <h2 class="subheadline"><?php echo $data->subheadline()->html() ?></h2>
    <?php
        // Convert the selected filename to a full file object
        $filename = $data->intro();
        $intro = $data->files()->find($filename);
    ?>
    <!-- Use the file object -->
    <img src="<?php echo $intro->url(); ?>" />

Yep, I try to build a one-page Website.
I tried your latest snippet and it works fine now !
Thank you both for the help =)

1 Like

You’re very welcome!

Hey @DieserJonas,

I don’t know f you are still maintaining this plugin. But with V2.2 your plugin is broken.
The checkboxes aren’t working anymore.

Do you mind to take a look?

Sure I still maintain it. I know that it’s not yet compatible with Kirby 2.2 – I hope to get it updated within the next days though.

Awesome :+1: :+1: :+1:

Hi,
this plugin is awesome and it helped me a lot. However I have a functionality request:
Is it possible to add the option page to query images from another page?

something like this:

query: 
   page : another page
   label : selector label
   type  : selector
   autoselect: first
   types :
      - image

Thanks!

Please have a look at this related discussion. Feel free to chime in with your thoughts!

Hello,

I’ve some troubles using the plugin with Kirby 2.2.1

  • When I use “filter” option and try to select item, it redirects to the dashboard when clicking, and selection does not work.
  • If I do not use “filter” and try do add an item it redirects to site /panel/pages/home/upload with an error url message.

Please can you help?

Thank you very much,

Sorry, I did not saw the message above that says plugin is not yet compatible with 2.2

Hi @costa,

I just double check with the latest Kirby (+ Panel) release 2.2.1 and the latest Selector release 1.5.1. Unfortunately, I’m unable to reproduce the issues your experiencing.

As far as I can see the latest release is fully compatible to both Kirby 2.2.1 and Kirby 2.1.2.

Have you made sure that you’re really using the latest stable releases of both Kirby and the Selector?

Hi DieserJonas,

Exact, I was using an old version of Selector :frowning:
I just tried with the latest release and all work perfectly.

Thank you for your response and this very useful plugin.

You’re very welcome!

Just a side note. We now have a testkit for all default fields, third-party fields and other panel-related tests. The selector field is already included there and we couldn’t find any issues either: https://github.com/getkirby/testkit @DieserJonas feel free to use that for your own testing needs. One of our goals would be to introduce this as a central place for all plugin developers to build real-life test cases.

This looks really great! One question: if I wanted to remove the edit button, how would I go about doing that? I’m quite happy that this plugin works in a structured field, except for the edit button. I don’t mind losing that functionality there however (it is very nice mind you), and removing the button would make it a bit less cramped in the structured field entry form. In addition, removing edit and select button text would be nice.

Thank you!