By PeterChain on Wednesday, 16 July 2014
Posted in General Issues
Replies 13
Likes 0
Views 1.5K
Votes 0
Having read this information in your site: http://stackideas.com/docs/easyblog/customizations/blog-images

I would like to know:

How to define a default blog image for each new post.

What would be the code to change a blog image externally from another component or piece of PHP code. I guess there is an EasyBLog defined function as simple as the one to retrieve the image.
Hello Pere,

I believe you are trying to determine if there's no blog image assigned to a blog post, then display a default image? If you are using the default theme, edit the file /components/com_easyblog/themes/default/blog.item.php and at line 64 locate the codes below,


<!-- Blog Image -->
<?php if( $row->getImage() && $this->getParam( 'blogimage_frontpage') ){ ?>
<a href="<?php echo EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id='.$row->id); ?>" title="<?php echo $this->escape( $row->title );?>" class="blog-image float-l mrm mbm">
<img src="<?php echo $row->getImage()->getSource( 'frontpage' );?>" alt="<?php echo $this->escape( $row->title );?>" />
</a>
<?php } ?>


Replace it with,


<!-- Blog Image -->
<?php if( $row->getImage() && $this->getParam( 'blogimage_frontpage') ){ ?>
<a href="<?php echo EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id='.$row->id); ?>" title="<?php echo $this->escape( $row->title );?>" class="blog-image float-l mrm mbm">
<img src="<?php echo $row->getImage()->getSource( 'frontpage' );?>" alt="<?php echo $this->escape( $row->title );?>" />
</a>
<?php } else { ?>
<img src="path/to/your/image" />
<?php } ?>
·
Wednesday, 16 July 2014 23:56
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi! This is a good piece of code tweak that I will stroe in my archive for further use, but this is not exactly what I wanted.

What I need is that on the creation of a new post an image comes preloaded / preselected / prewhatever for the blog image so the author has the obligation to replace it for his own or assume this will be the default image until he does something.

I don't want to display a dummy image if the post lacks one, I want to put one as if it was selected by the author.

Maybe I could execute some kind of trigger plugin after the new post button is clicked?

Thank you.
·
Thursday, 17 July 2014 14:08
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello Pere,

Hm, I am not really sure what difference is this by pre-selecting an image and setting a default image if the image isn't there? Isn't it actually the same?
·
Friday, 18 July 2014 00:41
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi Mark,

thanks for your interest in giving sense to my petition.

Look, I decided to use the power of EasyBlog to complement some custom code for my Easyblog powered website. Sometimes the blog image would be used by my own code in a separate component and although I could make many tricks the optimal solution would be that there is always an image assigned for each post no matter is the same for many blogs.

That's it.

Could I trigger the code that loads an image selected through the media browser without needing to invoke the media browser?
·
Friday, 18 July 2014 03:32
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello Pere,

The "image" column in the table stores a json encoded string of an object. In other words, the logic behind it is something like this:

1. Image selected to be inserted as blog image
2. PHP END: Creates a php object that stores the information of the image
3. PHP END: Converts the php object into a json string using json_encode
4. PHP END: When retrieving the image, we use json_decode to convert the json string back into a php object.
·
Friday, 18 July 2014 10:28
·
0 Likes
·
0 Votes
·
0 Comments
·
Thank you Mark,

let's hope I'm able to handle something with this information and my limited code experience.
·
Saturday, 19 July 2014 00:10
·
0 Likes
·
0 Votes
·
0 Comments
·
No problem Pere
·
Saturday, 19 July 2014 15:06
·
0 Likes
·
0 Votes
·
0 Comments
·
Would be nice to define a standard image per categorie for example or generally.
Hacking is not worth and only for cracks. I am an Expert in my business and I dont want to be a php expert too :-)

It shouldnt be a small thing for you to implement this feature.
And you would make a lot of users really happy.

At least it would be cool, if there would also be a feater like "add standard image to posts without a blog image" ;-)

thanx in advance for your soon implemtation ;-)
·
Tuesday, 16 September 2014 00:27
·
0 Likes
·
0 Votes
·
0 Comments
·
Thanks for the heads up on this Joachim
·
Tuesday, 16 September 2014 00:37
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi,

sorry for such a long wait to answer, I made many tests and left this for a proper moment to attend again.

Looks like your suggested code would work but it has a minor flaw in my setup probably because I work in MAMP localhost by now.

The problem is that when a default image has to be shown in the <<EasyBlog » Frontpage Blog Layout>> view it works fine but

when an image is selected by the blog author then I get this path in the <<EasyBlog » Frontpage Blog Layout>> view

http://localhost:8888/http://localhost:8888/scaleauto/images/easyblog_shared/TrackThumbs/2e1ax_yoo_avenue_frontpage_International-39.gif


so, could you assess me on how to build a correct path? Is something wrong in your suggested code or shall I change my joomla or server config?

Thank you.
·
Monday, 22 September 2014 20:30
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello Pere,

To be honest with you, I am not really sure why the URLs are being "duplicated" but the only way for me to actually test this is to test it on your live site. Can you please start a new thread and provide us with the access to the test site so that we can check on this?
·
Tuesday, 23 September 2014 02:20
·
0 Likes
·
0 Votes
·
0 Comments
·
I'll will upload the project to a server tomorrow and then go back to you with logins and details.

Thanks a lot for your interest.
·
Tuesday, 23 September 2014 02:29
·
0 Likes
·
0 Votes
·
0 Comments
·
Thanks Pere By the way, please start a new thread once you have done that and provide us the steps to reproduce this error because I think this thread is already pretty old
·
Tuesday, 23 September 2014 02:38
·
0 Likes
·
0 Votes
·
0 Comments
·
View Full Post