Viewing 2 reply threads
  • Author
    Posts
    • #6940
      pionect
      Member

      We implemented a piklist field which allows for a single image to be selected.

      
          piklist('field', [
              'type'     => 'file',
              'field'    => 'background_image',
              'scope'    => 'post_meta',
              'label'    => __('Page background image', 'theme'),
              'validate' => [
                  [
                      'type'    => 'limit',
                      'options' => [
                          'min' => 1,
                          'max' => 1
                      ],
                      'message' => __('Sorry, you can only select one image for this.', 'theme')
                  ]
              ]
          ]);
      

      The website is in production for a few months now and the backgrounds have been changed recently. So the site admin uploaded new backgrounds and removed the old ones in the media library. Later on she tried to apply the new ones to pages. On the specific pages the background field didn’t show an image, because it’s deleted, but it did still contain a reference to the deleted media. So when she added the new image, the field denied to save and gave the warning that only a single image can be saved. The only current solution is that we manually remove all the outdated references.

      I’d like to see that Piklist would check the integrity of the media reference when the edit screen is loaded. So it wouldn’t add the hidden reference to the html in the first place. When the page is saved it wouldn’t have to know that there was a deprecated reference in the first place.

    • #6950
      Steve
      Keymaster

      @pionect– We’re aware of this issue and it’s something on our list of todo’s. Sorry for the inconvenience.

    • #6968
      Jason
      Keymaster

      Hey @pionect!

      Just fixed this bug. Glad to finally have it done. That bug has bit me on projects in the path, unfortunately I was always busy doing what I needed to get done and didn’t have time. Now it’s fixed!

      To tie you over until the next version of Piklist is released with the fix, I’ve provided the patch for the fix. In case you don’t know, just go to the piklist directory and do git apply file-fix.patch — assuming you’ve placed the file in the piklist directory. Otherwise you can always just read the file and apply the patch yourself. 🙂

      Patch: https://dl.dropboxusercontent.com/u/1392338/file-fix.patch

      Hope this helps!

Viewing 2 reply threads
  • You must be logged in to reply to this topic.