justb3a

Module: Image Extra

108 posts in this topic

10 hours ago, justb3a said:

One opportunity would be to use a `label` element if it isn't a multilingual site and a `strong` tag if it is one.  What do you think?

Sounds good, thanks.

10 hours ago, justb3a said:

The idea behind this was that some textformatter like "NewLineToBreak" or "NewLineToListItem" doesn't make that much sense applied to an one liner input element.

True, but the textformatter that I'm thinking of is HTML Entity Encoder, which is important for any text field to avoid ambiguous ampersands or other invalid HTML. The string could be manually encoded in the template but more convenient to set-and-forget with a textformatter. :)

Share this post


Link to post
Share on other sites

Hi,

Thanks so much - that makes sense... I've tried to combine the below in a lot of different ways but keep getting an error...

Any ideas?

Thanks

<?php
if ($image->caption){
    //Output markup 1
}
else {
    //Output markup 2
}
?>

<?foreach($page->images as $image) {
 $thumb = $image->width(1040); 
echo "<li><img src='$thumb->url' alt='$image->description'><p class='caption'><strong>{$image->imagetitle}</strong> <em>{$image->imagetext}</em> <span><br>{$image->role}</span></p></li>";}
?>

 

Edited by kongondo
Mod Note: Moved your question to this module's support forum

Share this post


Link to post
Share on other sites

hi!
thanks for this great module!

today I experienced a strange issue when using this module with the Video Fieldtype Module
I get the following error when uploading a video, when the image extra module is installed:

<br />
<b>Notice</b>:  Trying to get property of non-object in <b>/www/htdocs/w00dd152/projekte/jp-relaunch/site/modules/ImageExtra/ImageExtra.module</b> on line <b>722</b><br />
[{"error":false,"message":"Added file: portfolio_screencap_02.mp4","file":"\/jp-relaunch\/site\/assets\/files\/1162\/portfolio_screencap_02.mp4","size":3214711,"markup":"<li id='file_c17b44756649023a42ba014c5b29202c' class='InputfieldFile InputfieldImage InputfieldVideo ui-widget'>\n\t\t<p class='InputfieldFileInfo ui-widget ui-widget-header'>\n\t\t\t<span class='ui-icon ui-icon-arrowthick-2-n-s'><\/span>\n\t\t\t<span class='InputfieldFileName'>portfolio_screencap_02.mp4<\/span> \n\t\t\t<span class='InputfieldFileStats'>• 3,139 kB • <\/span> \n\t\t\t<label class='InputfieldFileDelete'><input type='checkbox' name='delete_video_repeater1162_c17b44756649023a42ba014c5b29202c' value='1' \/><span class='ui-icon ui-icon-trash'>Delete<\/span><\/label>\n\t\t\t<a class='InputfieldFileMove InputfieldFileMoveBottom' href='#'><span class='ui-icon ui-icon-arrowthickstop-1-s'><\/span><\/a> \n\t\t\t<a class='InputfieldFileMove InputfieldFileMoveTop' href='#'><span class='ui-icon ui-icon-arrowthickstop-1-n'><\/span><\/a> \n\t\t<\/p>\n\t\t\t<div class='InputfieldFileDescription'><label for='description_video_repeater1162_c17b44756649023a42ba014c5b29202c' class='detail'>Description<\/label><input type='text' name='description_video_repeater1162_c17b44756649023a42ba014c5b29202c' id='description_video_repeater1162_c17b44756649023a42ba014c5b29202c' value='' \/><\/div>\n\t\t<br \/><label class='InputfieldFileDescription'><span class='detail'>Subtitles<\/span>\n\t\t<br \/><br \/>In templates, you can access this subtitles file (portfolio_screencap_02.srt) using: <code>$page->video->eq(0)->subtitles<\/code><br \/>In templates you can access a formatted transcript (converted from subtitles entered in SRT format), by using: <code>$page->video->eq(0)->transcript<\/code>\n\t\t<br \/><br \/><textarea rows='10' name='subtitles_video_repeater1162_c17b44756649023a42ba014c5b29202c' \/><\/textarea>\n\t\t\t<input class='InputfieldFileSort' type='text' name='sort_video_repeater1162_c17b44756649023a42ba014c5b29202c' value='0' \/>\n\t\t<\/p><\/li>","replace":false,"overwrite":0}]

I testes this in PW 3.0 with the newest versions of both modules installed.
Not sure why its even interfering with the video field..
When I disable the image extra module, everything works fine.

Share this post


Link to post
Share on other sites

@jploch - I'd like to see a dump of $event after line 718 because $field is not an object and it should be.

That said, a quick fix might be to change the hook on line 97 to:

InputfieldImage::processInputFile

 

1 person likes this

Share this post


Link to post
Share on other sites
20 hours ago, adrian said:

@jploch - I'd like to see a dump of $event after line 718 because $field is not an object and it should be.

That said, a quick fix might be to change the hook on line 97 to:


InputfieldImage::processInputFile

 

Thx! this fixed it for me

1 person likes this

Share this post


Link to post
Share on other sites

@Jon E 

Just use the comparison inside the foreach loop:

foreach ($page->images as $image) {
  $caption = '';
  if ($image->imagetitle) {
    $caption = "<p class='caption'>{$image->imagetitle}</p>";
  }

  echo "<li><img src='{$image->width(1040)->url}' alt='{$image->description}'>$caption</li>";
}

Or if you want to combine multiple parts: you can check every extra field individually and concatenate the caption before outputting it.

foreach ($page->images as $image) {
  $caption = '';
  if ($image->imagetitle) $caption .= "<strong>{$image->imagetitle}</strong>";
  if ($image->imagetext) $caption .= "<em>{$image->imagetext}</em>";
  if ($image->role) $caption .= "<span>{$image->role}</span>";
  if ($caption) $caption = "<p class='caption'>$caption</p>";

  echo "<li><img src='{$image->width(1040)->url}' alt='{$image->description}'>$caption</li>";
}

 

1 person likes this

Share this post


Link to post
Share on other sites

New Version 1.0.4:

@Robin S  use label tag if it isn't a multilangual site

@jploch, @adrian changed hook InputfieldFile::processInputFile to InputfieldImage::processInputFile

4 people like this

Share this post


Link to post
Share on other sites

Hi there! And, as always, thanks for a perfect product!

Would like to discuss an interesting case. Let's suppose we have some images attached to different pages, each image having some extra fields including uid field which is unique. We have to build an api page which should receive requests like /api?uid=efv97yg and it should return some JSON about the image with that uid.

Is there any possibility to find an image by its extrafield value (e.g. uid)? Well, i know that we can do something like this:

$pages_ = $pages->find('template=page_with_fotos');
foreach($pages_ as $page_)
	{
	$images = $page_->images;
	foreach($images as $image)
		{
		if($image->uid !== $uid) continue;
		$json = json_encode($image);
		break;
		}
	}
echo $json;

But its not very elegant.

And even worse:

$sql = "select * from field_foto where uid=$uid";
$query = $database->prepare($sql);
$query->execute();
...

What is on my wishlist:

//pseudocode, will NOT work for sure!

$foto = $field_fotos->get("uid=$uid");
...

Will appreciate any advice. Thanks!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By FIA2008
      How can I change the output of `Page::render`?
      I've created a hook before page::render, but when I set the $event->return to something else, my whole page is replaced with that value.
      For example:
       
      public function beforePageRender(HookEvent $event) { $event->return = 'blaat'; } This will cause my whole page to be nothing more than just 'blaat'.
      What I want, is that my menu, footer etc. are still visible but only the content of that page is replaced.
    • By kixe
      Today I have been running in mysql errors using @renobird s Module MarkupActivityLog which still uses mysqli Driver.
      @all developers
      Although mysqli is still supported PDO driver is the default database driver in PW since https://processwire.com/about/news/introducing-processwire-2.4/
      and its strongly recommend to all module authors to use/change-to PDO driver instead of mysqli.

      @renobird I have sent a pull request.
       
    • By Nurguly Ashyrov
      NOTE: This thread originally started in the Pub section of the forum. Since we moved it into the Plugin/Modules section I edited this post to meet the guidelines but also left the original content so that the replies can make sense.  
      ProcessGraphQL
      ProcessGraphQL seamlessly integrates to your ProcessWire web app and allows you to serve the GraphQL api of your existing content. You don't need to apply changes to your content or it's structure. Just choose what you want to serve via GraphQL and your API is ready.
      Warning: The module supports PHP version >= 5.5 and ProcessWire version >= 3.
      Links:
      Zip Download Github Repo ScreenCast  
      At this moment the module is not available from the modules section. Please refer to the Readme to learn more about how to use the module.
       
      Original post starts here...
      Hi Everyone! I became very interested in this GraphQL thing lately and decided to learn a bit about it. And what is the better way of learning a new thing than making a ProcessWire module out of it! 
      For those who are wondering what GraphQL is, in short, it is an alternative to REST. I couldn't find the thread but I remember that Ryan was not very happy with the REST and did not see much value in it. He offered his own AJAX API instead, but it doesn't seem to be supported much by him, and was never published to official modules directory. While ProcessWire's API is already amazing and allows you to quickly serve your content in any format with less than ten lines of code, I think it might be convenient to install a module and have JSON access to all of your content instantly. Especially this could be useful for developers that use ProcessWire as a framework instead of CMS.
      GraphQL is much more flexible than REST. In fact you can build queries in GraphQL with the same patterns you do with ProcessWire API.
      Ok, Ok. Enough talk. Here is what the module does after just installing it into skyscrapers profile.

      It supports filtering via ProcessWire selectors and complex fields like FieldtypeImage or FieldtypePage. See more demo here
      The module is ready to be used, but there are lots of things could be added to it. Like supporting any type of fields via third party modules, authentication, permissions on field level, optimization and so on. I would love to continue to develop it further if I would only know that there is an interest in it. It would be great to hear some feedback from you. I did not open a thread in modules section of the forum because I wanted to be sure there is interest  in it first.
      You can install and learn about it more from it's repository. It should work with PHP >=5.5 and ProcessWire 3.x.x. The support for 2.x.x version is not planned yet.
      Please open an issue if you find bugs or you want some features added in issue tracker. Or you can share your experience with the module here in this thread.
    • By Macrura
      Released:
      http://modules.processwire.com/modules/jquery-ion-range-slider/
      The built in rangeslider is good, but it is somewhat limited if you need really specific slider interfaces, like with pips and showing the value on the handles.
      There are many Jquery rangesliders, but one of the best and easiest to implement is the ion.rangeSlider.
      http://ionden.com/a/plugins/ion.rangeSlider/en.html
      This is a preview of the very simple module that basically allows you to enable the ion.Rangeslider on any text input, and then you type in your params into the textarea field (careful, you can break the page's javascrpt if you are not careful!) There are way too many options to really make this configurable, so the easiest way it to have a free text field where you enter any params. The params are just passed to the instance of the slider.
      Features of ion.Rangeslider:
      Skin support. (5 skins included and PSD for skin creation) Any number of sliders at one page without conflicts and big performance problems Two slider types single (1 slider) and double (2 sliders) Support of negative and fractional values Ability to set custom step and snap grid to step Support of custom values diapason Customisable grid of values Ability to disable UI elements (min and max, current value, grid) Postfixes and prefixes for your numbers ($20, 20 € etc.) Additional postfix for maximum value (eg. $0 — $100+) Ability to prettify large numbers (eg. 10000000 -> 10 000 000 or 10.000.000) Slider writes its value right into input value field. This makes it easy to use in any html form Any slider value can be set through input data-attribute (eg. data-min="10") Slider supports disable param. You can set it true to make slider inactive Slider supports external methods (update, reset and remove) to control it after creation For advanced users slider has callbacks (onStart, onChange, onFinish, onUpdate). Slider pastes all its params to callback first argument as object Slider supports date and time  
      Screenshots comparing Inputfield Rangeslider (Soma) vs. JqueryIonRangeSlider...
      1) basic range using currency
      '
      Same with different skin

      Range of years

      Same with narrower column and different skin..

       
      the module is functional and being used on 1 site, but some additional testing is needed...
    • By FIA2008
      I'm using PHPdocumentor to generate documentation of my modules, but it fails to scan the .module files. Is there another way of making processwire see a module other than giving it a .module extension?
      I'd like to rename my module file to .php but then processwire no longer sees my module.