Boostrap image responsive in Codeigniter - php

It's first time when i use Codeigniter, so I tried to work with Bootstrap. I knew Bootstrap has a class for images: img-responsive, but you can only use a parameter in img() codeigniter function. So , i tried something like this:
$logo = array(
'src' => 'assets/images/logo.png',
'class' => 'img-responsive',
);
Then i included $logo into img($logo). If I check View Source of page, link looks like:
<img src="http://localhost/assets/images/logo.png" class="img-responsive" alt="" />
but image is not responsive. Any idea ?

Related

How i can get full relative path of image in cakephp 3.1?

I want to send email with images, and image has must full path,
Like, http://www.example.com/img/image-name.jpg
So, I'm using cakephp 3 framework with code:
$this->Html->image('image.jpg', ['fullBase' => true]);
Error accurs: Path is not found
I think webroot always work: <img src="<?php echo $this->webroot; ?>img/image-name.jpg"> But this is not proper way.
Please suggest proper way with example.
Thanks
Mak.
For the email sending, you must have to full path of the image,
`echo $this->Html->image("recipes/6.jpg", [
"alt" => "Brownies",
'url' => ['controller' => 'Recipes', 'action' => 'view', 6]
]);`
Will output:
`<a href="/recipes/view/6">
<img src="/img/recipes/6.jpg" alt="Brownies" />
</a>`
But you have to use,
echo $this->Html->image("logo.png", ['fullBase' => true]);
Will output:
<img src="http://example.com/img/logo.jpg" alt="" />
https://book.cakephp.org/3.0/en/views/helpers/html.html#linking-to-images
This is a proper way that suggested by CakePhp framework.

Drupal-7 rss feed icon to text

I am looking for a way to modify the default Views feed icon from an image to a text value. I have found several cases where people change the default image to a new image, but I prefer working with fonts as they look more crisp regardless of resolution or device.
The idea is to replace the image with a FontAwesome icon (fa-rss-square, &#xf143). I have had succes with changing the default text in the search-block, ie.:
function theme_form_alter(&$form, &$form_state, $form_id) {
if($form_id == 'search_block_form') {
$form['actions']['submit']['#value'] = decode_entities('');
}
}
I am a newbie when it comes to php, so my attempts of modifying the hook explained in the Drupal-API has not worked (thus far):
function theme_feed_icon($variables) {
$text = t('Subscribe to !feed-title', array('!feed-title' => $variables['title']));
if ($image = theme('image', array('path' => 'misc/feed.png', 'width' => 16, 'height' => 16, 'alt' => $text))) {
return l($image, $variables['url'], array('html' => TRUE, 'attributes' => array('class' => array('feed-icon'), 'title' => $text)));
}
}
The current output looks like this:
<div class="feed-icon">
<img typeof="foaf:Image" src="mywebsite/misc/feed.png" width="16" height="16" alt="Subscribe to news from my website">
</div>
I'd like to keep the div and its class, but only have the font/text link inside, preferably without the same class. I'd appreciate any clever advice :-)
you could avoid printing the feed icon from php and just enter the html code either in the footer or the header of the view from the UI
or
you could hide the image via CSS, and use
.feed-icon:before {
font-family: FontAwesome;
content: "\f143";
}

What php to use to be able to pick an image from the Wordpress library

This is the original php code:
function lovethemes_pricing_shortcode($atts)
{extract(shortcode_atts(array(
"heading" => '',
"price" => '',
"link" => '',
"name" => '',
), $atts ) );
return '<div class="pricing animated bounceIn">
<section class="head">'.heading.'
<section class="content">
<ul><li class="price">'.$price.'</li>
<li>'.$name.'</li>
</ul></section> </div>';}
add_shortcode('pricing', 'lovethemes_pricing_shortcode');
This is what is written on my page in the backend:
[pricing heading="7 februari 2015"
price="Strak bekleden van een taart"
link="/agenda/workshops/strak-bekleden-van-een-fondant-taart"
name="Info"]
Resulting in this:
http://www.alexandra-van-zandbergen.be/wp-content/uploads/2015/08/Schermafbeelding-2015-08-08-om-13.23.38.png
And what I would like to have is this:
http://www.alexandra-van-zandbergen.be/wp-content/uploads/2015/08/Schermafbeelding-2015-08-08-om-13.22.47.png
I can read and write html and css but no php... Can anyone help me with this please? I've tried to add several codes and nothing is working.
I have to be able to change the image in the backend, I would like to be able to just choose an image from the Wordpress image gallery.
Thanks in advance!
Alexandra
I'm not very familiar with it either, and would need to try it to see if it works, so pls don't shoot me if it does not. However, this function makes use of the shortcode API.
The code tells to create a [pricing] shortcode, currently with 4 attributes. So, if all the rest works, then you most likely can simply add another one.
What I do not understand - and I'm not taking the time to look it up - is why all variables in your code start with $, but not the heading. I'll ignore that since it doesn't seem to be the problem.
Note:
It's best to add:
the image size to the HTML for performance. I'm assuming that you'll
use images of the same size. If you would want to set the image
size, you can create attributes for it too.
an alt text for SEO. Below I use the price attribute.
While I'm at it I would suggest to add a link to the image and title too. People sometimes click on it instead of on the info button. This would make it more user friendly.
So, it then would look like this:
function lovethemes_pricing_shortcode($atts) {
extract(shortcode_atts(array(
"heading" => '',
"price" => '',
"link" => '',
"name" => '',
"img" => '',
), $atts ) );
return '<div class="pricing animated bounceIn">
<section class="head">'.heading.'
<section class="content">
<ul><li class="price">'.$price.'</li>
<li><img src="'.$img.'" alt="'.$price.'" width="247" height="186" /></li>
<li>'.$name.'</li>
</ul></section></div>';
}
add_shortcode('pricing', 'lovethemes_pricing_shortcode');
and your shortcode would be:
[pricing heading="7 februari 2015"
price="Strak bekleden van een taart"
link="/agenda/workshops/strak-bekleden-van-een-fondant-taart"
img="/your/image/url.jpg"
name="Info"]
To make it a little more user friendly, you could also rename the attributes to something that corresponds to the content, f.ex. heading > date
I hope this helps!

Laravel + CodeSleeve stapler bundle

I am using the Codesleeve Stapler and i have a small problem.
I did exactly what the last example described on this page:
https://github.com/CodeSleeve/stapler
The difference is that my new model is called Pictures instead of ProfilePictures
and my model is not User but Trip.
The <img src="<?= asset($picture->photo->url('thumbnail')) ?>">
on the view shows the last picture that has been uploaded.
I want to show the Picture that belongs to each Trip. How could i perform this?
Thanks.
So, you have two models: 'Trip', and 'Picture'. In your Trip model, you need to define a 'hasMany' relationship to the Picture model:
public function pictures(){
return $this->hasMany('Picture');
}
Then, in your Picture model, you define the Stapler attachment:
// Be sure and use the stapler trait, this will not work if you don't:
use Codesleeve\Stapler\Stapler;
// In your model's constructor function, define your attachment:
public function __construct(array $attributes = array()) {
// Pictures have an attached file (we'll call it image, but you can name it whatever you like).
$this->hasAttachedFile('image', [
'styles' => [
'thumbnail' => '100x100#',
'foo' => '75x75',
'bar' => '50x50'
]
]);
parent::__construct($attributes);
}
Now that you've defined the attachment on the Picture model, every time you access a Picture object, you'll also have access to the file attachment. Assuming you had a Trip record, you could do this:
<?php foreach ($trip->pictures as $picture): ?>
<img src="<?= asset($picture->image->url('thumbnail')) ?>">
<?php endforeach ?>
You could access the original image like this:
<img src="<?= asset($picture->image->url()) ?>">
// or
<img src="<?= asset($picture->image->url('original')) ?>">
In fact, you can access any of the style you defined:
<img src="<?= asset($picture->image->url('foo')) ?>">
<img src="<?= asset($picture->image->url('bar')) ?>">
Hope this helps.

How to add non HTML attribute in Yii's chtml::image htmloptions

I am trying to add non HTML attribute in htmlOptions array of Yii's CHTML::image($url, $alt, $htmlOptions), but in rendered page these attributes does not get added.
Basically i want to use lazy loading of images which needs to store original image url in 'data-origional' and a placeholder in SRC tag. attribute. For some reasons i can't use a direct HTML <img /> tag in my code.
Thanks for any suggestions guys.
This code works fine:
echo CHtml::image('http://google.com/images/srpr/logo3w.png', '', array(
'data-original' => 'original',
'another-attribute' => 'bla-bla-bla',
));
It returns:
<img
alt="" src="http://google.com/images/srpr/logo3w.png"
another-attribute="bla-bla-bla"
data-original="original"
>

Categories