Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2023-03-13 13:08:37

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,445
Website GitHub

Re: Any solution to find and use the uploaded images in article?

Awesome, thank you. I’ve been busy with com_connect too :)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#14 2023-03-13 14:58:39

etc
Developer
Registered: 2010-11-11
Posts: 5,186
Website GitHub

Re: Any solution to find and use the uploaded images in article?

Done as a pre-release version, testers/help contributors welcome. Remove (or change .php extension of) the cached version first. Will probably not work in multi-site setup atm, we need to tweak PLUGINPATH or introduce PLUGINURL constant in core.

Offline

#15 2023-03-13 15:12:23

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,445
Website GitHub

Re: Any solution to find and use the uploaded images in article?

etc wrote #335066:

Done as a pre-release version.

Awww, no commits? Thanks for the release though, I’ll give it a run through when I get a chance.

Will probably not work in multi-site setup atm, we need to tweak PLUGINPATH or introduce PLUGINURL constant in core.

I thought it already took advantage of multi-site? Or do we need to do more beyond this:

if (!defined('PLUGINPATH')) {
    global $txpcfg;
    $admin_path = (isset($txpcfg['multisite_root_path'])) ? $txpcfg['multisite_root_path'].DS.'admin' : txpath;
    define('PLUGINPATH', $admin_path.DS.'plugins');
}

The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#16 2023-03-13 15:52:22

etc
Developer
Registered: 2010-11-11
Posts: 5,186
Website GitHub

Re: Any solution to find and use the uploaded images in article?

Bloke wrote #335067:

Awww, no commits? Thanks for the release though, I’ll give it a run through when I get a chance.

I’m totally ignorant of Git workflow, if anybody asked :-/

I thought it already took advantage of multi-site? Or do we need to do more beyond this:

Yep, but this is a fs path, not always suitable in URL (to access plugin assets like css an js).

Offline

#17 2023-03-13 16:04:55

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,445
Website GitHub

Re: Any solution to find and use the uploaded images in article?

etc wrote #335068:

this is a fs path, not always suitable in URL.

True. If we need something to get to plugin resources then it’ll be damn useful I’m sure.

Edit: I suspect introducing a new convention here for the layout of a plugin folder would be beneficial. We already have a loose spec, but if we document it and make it concrete then it makes core’s job easier to define paths to find stuff within it. E.g. manifest file, php source, help, scripts, styles etc.

Last edited by Bloke (2023-03-13 16:43:48)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#18 2023-03-14 05:46:35

phiw13
Plugin Author
From: Japan
Registered: 2004-02-27
Posts: 3,187
Website

Re: Any solution to find and use the uploaded images in article?

Plugin works OK, I think. The search is a little puzzling though. I input an image “name”, press return; it appears to load a bunch of images not necessary related (I don’t have many images uploaded on the test site).

2 issues:
  1. if the site uses custom path to the plugins folder (in my case, domain.local/core_plugins, defined in config.php), the path to the stylesheet and script is wrong (it looks for /textpattern/plugins…)
  2. at my first attempt, script and styles were blocked… Could you please, in a next version, make the script and style blocks CSP aware? Example by Stef on one of his plugins.

After downloading from GitHub, I installed the plugin by uploading the whole zip folder through the TXP admin UI.

Last edited by phiw13 (2023-03-14 05:50:31)


Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern

Offline

#19 2023-03-14 12:57:01

etc
Developer
Registered: 2010-11-11
Posts: 5,186
Website GitHub

Re: Any solution to find and use the uploaded images in article?

I have uploaded v.0.4 (zip only atm), please test.

What’s new?

  • Image search fields pref. If empty, will use the search options of Images tab (as in v.0.3).
  • Search results can be scrolled with Down and Up keys and reset with Esc.
  • Minor improvements and bugfixes.

The plugin directory is still hard-coded, since I was not able to use PLUGINPATH constant in URL. Change it in the code if needed, will fix later.

Offline

#20 2023-03-15 05:23:54

phiw13
Plugin Author
From: Japan
Registered: 2004-02-27
Posts: 3,187
Website

Re: Any solution to find and use the uploaded images in article?

This works nicely now – both the Upload part and the Find part. I tested this on my normal playground with 300+ images. Find: e.g type 2 digits and I get –quickly– a list of possible images.

One small UI suggestion: limit the height of the image containers (in case there are multiple images in the article_image field):

#article-file-container, #article-file-select { 
  max-height: 40vh;
  overflow:auto;
}

Oh, and check, CSP! For the inline onchange="comArticleImagePreview(this)", here is the hash for the script-src-attr

SHA256-S0Fa8QCxrGu3S55pAHU+jjOoI1PaLPGe2nF4gsfG3zA=

Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern

Offline

#21 2023-03-15 08:18:25

etc
Developer
Registered: 2010-11-11
Posts: 5,186
Website GitHub

Re: Any solution to find and use the uploaded images in article?

phiw13 wrote #335076:

One small UI suggestion: limit the height of the image containers (in case there are multiple images in the article_image field):

Good idea, certainly better than limiting the number of visible images via CSS. Will test, thanks.

Oh, and check, CSP! For the inline onchange="comArticleImagePreview(this)", here is the hash for the script-src-attr

That’s an old days relics, I will rather move it to a listener.

Offline

#22 2023-03-15 09:19:53

phiw13
Plugin Author
From: Japan
Registered: 2004-02-27
Posts: 3,187
Website

Re: Any solution to find and use the uploaded images in article?

etc wrote #335078:

That’s an old days relics, I will rather move it to a listener.

That would be even better. TY.

Last edited by phiw13 (2023-03-15 09:20:08)


Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern

Offline

#23 2023-03-15 09:59:43

etc
Developer
Registered: 2010-11-11
Posts: 5,186
Website GitHub

Re: Any solution to find and use the uploaded images in article?

Okay, updated, seems to work fine. Please test, if everything is ok I will do some clean up.

News:

  • Scrollable image areas, change its height in style.css if needed.
  • Deletable images in the image select area.
  • Add link to append all filtered images at once.

Offline

#24 2023-03-16 03:09:40

phiw13
Plugin Author
From: Japan
Registered: 2004-02-27
Posts: 3,187
Website

Re: Any solution to find and use the uploaded images in article?

Overall, it works great

One small issue that you probably know: $pluginpath for the script – it works great for the stylesheet. The path for the script is still hard coded; I managed to get $pluginpath working for the script, but I had to repeat the code block

plugin function  js()
{
    global $img_dir, $path_to_site;
    $pluginpath = str_replace($path_to_site, '..', PLUGINPATH);//dmp($pluginpath);
// and then add $pluginpath to the path.

More UI goodness: scroll snap on the image containers:

#article-file-container,
#article-file-select {
    scroll-snap-type: y mandatory;
}

#article-file-container p,
#article-file-select p {
     scroll-snap-align: start;
}

When scrolling the image “snaps” to the top edge of the container. BTW, consider adding a shared class to those two image containers; that makes it easier to write styles.

And thank you for removing the inline js thingie. This quickly becomes a model plugin for CSP handling in plugins.


Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern

Offline

Board footer

Powered by FluxBB