-
Posts
1,306 -
Joined
-
Last visited
-
Days Won
13
Everything posted by Juergen
-
Add additonal settings to image field in template context
Juergen replied to Juergen's topic in API & Templates
These are the only settings that I found that may work: $allowables = ['maxFiles', 'defaultValuePage', 'outputFormat', 'extensions', 'outputString', 'useTags', 'tagsList']; But what I need is to add "minWidth" at least, because I have very large images for a slider too. Therefore I need to adjust this setting. Otherwise I have to create a new image field for the slider images. -
Add additonal settings to image field in template context
Juergen replied to Juergen's topic in API & Templates
No this is correct in this case (take a look at https://abdus.co/blog/doing-more-with-fewer-fields-in-processwire/), but it seems that the settings I want to include are not supported in this case. This example from Abdus blog works: $this->addHookMethod('FieldtypeFile::getConfigAllowContext', function (HookEvent $e) { $allowables = ['maxFiles', 'defaultValuePage', 'outputFormat']; $e->return = array_merge($e->return, $allowables); }); In this case it doesnt matter if you use "FieldtypeImage" or "FieldtypeFile" - both work. The settings "maxFiles, defaultValuePage and outputFormat" work, but "minWidth, minHeight" and so on not. -
Hello, I am trying to add additional settings to an image field depending on template context with this piece of code inside my ready.php: //Image field $wire->addHookMethod('FieldtypeImage::getConfigAllowContext', function (HookEvent $e) { $allowables = ['minWidth', 'minHeight', 'noLang', 'clientQuality']; $e->return = array_merge($e->return, $allowables); }); Unfortunately the settings will not be displayed if I am inside the template fields settings page. Can someone help me out what is missing in this case? Thanks
-
I often use this library with composer: https://github.com/oscarotero/social-links Can show total of shares too! Design can be made with CSS individually.
- 9 replies
-
- 1
-
- website
- share buttons
-
(and 1 more)
Tagged with:
-
- 30 replies
-
- antispiders
- anticrawler
-
(and 2 more)
Tagged with:
-
This link under the download section leads to this Processwire page and not to Github because the href value is empty.
- 30 replies
-
- 2
-
- antispiders
- anticrawler
-
(and 2 more)
Tagged with:
-
The cropping works now also fine in my case, the only difference is in outputting the coordinates. If it is an image array you can use $image->focus() but if your image is not in array you have to use $image->focus -> without brackets I was a little bit confused for the first time, because I have used a square crop and therefore the crop focus seems to be in center instead of the coordinates. So I wanted to check if the focus coordinates are still there. Therefore I have needed to output the coordinates.
-
Ok I found the cause. There was a wrong setting in my image field. You have to set it to output an array of elements instead of a single element. My image field only allows 1 image so I set it to auto. This caused the behavior.
-
Ok, I have created a new image field and now everything works fine. So it seems that there was a problem with my old image field.
-
Strange behavior, I have to investigate further. What I also have discovered is that the duplicate action is no longer present in the dropdown.
-
I use 7.0.27. I have croppable image installed too. My first thought was that there is an interference between the default image field and croppable image 3.
-
The image is there and now I get the focus coordinates if I remove the brackets. This works: print_r($child->singleimage->focus); but this not: print_r($child->singleimage->focus());
-
Great addition, but I have problems focusing images via $page->children call. Description: If I output the image on the same page the focus works, but if I call it from another page I cannot get the focused image. Focus is centered in this case. foreach ($page->children as $child) { $image = $child->myimagefield; print_r($image->focus()); } This will lead to following error message: Call to a member function focus() on null. Can someone confirm this behaviour? Best regards
-
You can also use the following code in your site/ready.php: <?php if($page->template->hasField('name-of-your-ckeditor-field')){ $string = $page->name-of-your-ckeditor-field; //create string replace for blockquote $string = str_replace('<blockquote>', '<blockquote class="blockquote">', $string); //here you can add further manipulations.... //.............. //finally set the value back with manipulations $page->name-of-your-ckeditor-field = $string; } Replace "name-of-your-ckeditor-field" with the name of your field. In this case you can use the default blockquote button from CKEditor. Best regards
-
Hello thuijzer, I always get this error message after calling echo $page->field_name[1]->entries[0]->getFrom()->format('H:i'); in template: Cannot access private property ProcessWire\BusinessHoursDay::$entries Best regards
-
Thank you. I didnt know this. Now it works
-
Hello Adrian, I want to use the shortcut syntax $page->fieldname->formattedNumber on a file outside of the template folder (in my case a simple template which will be loaded via an Ajax call). But this doesnt work! In opposition $page->fieldname as standalone works. So the formatting object "formattedNumber" is not callable outside of the template folder. The file where I want to use it is located in /site/ajax/nameofthefile.php (outside of the template folder). I use the bootstrapping technique to get field values outside of PW templates folder. Is there a possiblility to load the module inside this template file so I can use formatted and unformatted numbers? Best regards
-
SEO and image cropping is also what I find very useful. In addition to image manipulations it would be great to add a feature that makes the scaling of images to FIT/FILL bounding boxes possible. Take a look at http://a32.me/2012/06/scale-images-to-fit-fill-bounding-box-in-php-using-gd/ for a detailed example. This is useful if you have images with different proportions fitting in a box (fe. logos of different partners, product images). Best regards
-
No, unfortunately not. The module cache is not responsible, also not the template cache. I have a lot of custom hooks inside my ready.php. Maybe one of them interferes with your code and prevents the adding of the js file. If no one other has to deal with this problem so it must be on my side. Its not a relevant issue for me at the moment. I guess I will find the reason - some day, some time
-
I dont know if I miss something, but the module only works in backend in my case. I have checked the loading of the js files in the frontend, but they are not there, if I am logged in as superuser. Is there something else that I have to do?
-
I am seeing this too.
-
Yes this was the issue. I followed your instructions and now it works as expected.
-
Would be great if the image field restriction also works with the croppable image field. At the moment it fetches all images which are of the croppable image fieldtype independent of the image field selection.
-
How to use a file inside templates folder outside of PW
Juergen replied to Juergen's topic in General Support
Using namespace Processwire in both files solves the problem. A writing mistake leads to that this approch did not work on the first attempt.