Keyword

Image not loading

  • Dave Spring
  • Dave Spring's Avatar Topic Author
  • Offline
  • New Member
More
8 years 8 months ago #150957 by Dave Spring
Image not loading was created by Dave Spring
When i filter between categories and tags, the results are coming up but the graphic associated with the item is not loading.

This is the code of my generic.php file - Am I missing something or is there something else I should check?

Any bit of help will be much appreciated......

K2HelperUtilities::setDefaultImage($this->item, 'itemlist', $this->params);
$mypagetitle = str_replace('k12', 'K-12', $this->params->get('page_title'));
?>

<div id="genericitemlist">
<!-- Page title -->
<h1 class="componentheading<?php echo $this->params->get('pageclass_sfx')?>"><?php echo $this->escape($mypagetitle); ?></h1>


<?php if(count($this->items)): ?>
<!-- Item list -->
<div class="itemList">
<!-- Secondary items -->
<div id="itemsListSecondary">
<?php foreach($this->items as $item) { ?>
<?php
$fields_var=json_decode($item->extra_fields, true);
$field1=$fields_var[0]["value"];
$field2=$fields_var[1]["value"];
?>
<div class="itemContainer" style="width:100%;">
<!-- Start K2 Item Layout -->
<div class="catItemView">
<div class="catItemImage">
<a href="<?php echo $this->item->link; ?>">
<img src="images/projects/<?php echo $field1 ?>" width="90" height="90" />
</a>
</div>

<div class="catItemDetails">

<div class="catItemTitle">
<a href="<?php echo $item->link; ?>">
<?php echo $item->title; ?>
</a>
</div>
<div class="catItemIntroText">
<?php echo K2HelperUtilities::wordLimit($item->introtext, 26); ?>
</div>
<div class="readMore">
<a href="<?php echo $item->link; ?>">
&raquo; View Project
</a>
</div>
<div class="clr"></div>


</div>
<div class="clr"></div>

</div>
<!-- End K2 Item Layout -->

Please Log in or Create an account to join the conversation.

  • Dave Spring
  • Dave Spring's Avatar Topic Author
  • Offline
  • New Member
More
8 years 8 months ago #150958 by Dave Spring
Replied by Dave Spring on topic Image not loading
Note it was working fine before and something changed and not sure what.

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 8 months ago #150975 by Krikor Boghossian
Replied by Krikor Boghossian on topic Image not loading
From what I can see, you are using an extrafield value to store the image's URL.

A more proper way to retrieve this information would be:
github.com/kricore/Advanced-templating-with-K2/blob/master/_inc/cheatsheet.php#L104-L109

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

  • Dave Spring
  • Dave Spring's Avatar Topic Author
  • Offline
  • New Member
More
8 years 7 months ago #151018 by Dave Spring
Replied by Dave Spring on topic Image not loading
The code I posted was working correctly prior to being spammed attacked. I clean up the site and I think all the code is but trying to make sure I didn't accidentally erase some code that I am not seeing from when I was cleaning it up.

Can't figure out what is causing the graphic not to load correctly. I just get a broken image icon. If this code looks good , is there any other files I need to check, that I maybe overlooking?

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 7 months ago #151020 by Krikor Boghossian
Replied by Krikor Boghossian on topic Image not loading
You are getting the image's source from an extrafield.
Make sure your extrafields structure has not been changed.
$field1=$fields_var[0]["value"];
If the first field was removed then you won't be able to print the value.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

  • Dave Spring
  • Dave Spring's Avatar Topic Author
  • Offline
  • New Member
More
8 years 7 months ago #151022 by Dave Spring
Replied by Dave Spring on topic Image not loading
The field structure is all the same.

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 7 months ago #151033 by Krikor Boghossian
Replied by Krikor Boghossian on topic Image not loading
Can you try echoing that field's value using the code I posted?
You have to use the field's however.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

  • Dave Spring
  • Dave Spring's Avatar Topic Author
  • Offline
  • New Member
More
8 years 7 months ago - 8 years 7 months ago #151042 by Dave Spring
Replied by Dave Spring on topic Image not loading
I tried using the code you gave me and there wasn't any change in the outcome. I tried it using the field and using the Alias.

As I inspected the page, it appears the echo is not returning the designated image. i.imgur.com/7nd2dXu.png

Here is the code for my Category_Item.php .........

K2HelperUtilities::setDefaultImage($this->item, 'itemlist', $this->params);

$fields_var=json_decode($this->item->extra_fields, true);
$field1=$fields_var[0]["value"];
$field2=$fields_var[1]["value"];

?>

<!-- Start K2 Item Layout -->
<div class="catItemView group<?php echo ucfirst($this->item->itemGroup); ?><?php if($this->item->params->get('pageclass_sfx')) echo ' '.$this->item->params->get('pageclass_sfx'); ?>">

<!-- Plugins: BeforeDisplay -->
<?php echo $this->item->event->BeforeDisplay; ?>

<!-- K2 Plugins: K2BeforeDisplay -->
<?php echo $this->item->event->K2BeforeDisplay; ?>



<div class="catItemDetails">

<div class="catItemImage">
<a href="<?php echo $this->item->link; ?>">
<img src="images/projects/<?php echo $field1 ?>" width="90" height="90" />
</a>
</div>

<div class="catItemTitle">
<a href="<?php echo $this->item->link; ?>">
<?php echo $this->item->title; ?>
</a>
</div>

<div class="catItemIntroText">
<?php echo $this->item->introtext; ?>
</div>
<div class="readMore">
<a href="<?php echo $this->item->link; ?>">
&raquo; View Project
</a>
</div>


</div>

</div>
<!-- End K2 Item Layout -->

This one is working and this loads the featured items in the list, i.imgur.com/UXpXTkY.png


Am I missing something or my eyes not seeing something?
Last edit: 8 years 7 months ago by Dave Spring. Reason: had to add links

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 7 months ago #151044 by Krikor Boghossian
Replied by Krikor Boghossian on topic Image not loading
Are extrafields enabled in the category view?

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

  • Dave Spring
  • Dave Spring's Avatar Topic Author
  • Offline
  • New Member
More
8 years 7 months ago #151059 by Dave Spring
Replied by Dave Spring on topic Image not loading
Yes they are

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum