Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ability to add attributes to html() method #46

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

abhimanyu003
Copy link
Contributor

Added ability to add attributes like id , class, alt to html() method
Uses

Image::open('open.jpg')
 ->html($title = 'some title', $type = 'jpg' , array('class'=>'test pull-right','id'=>'test','alt' => 'name')));

NULL can also be provided if don't want any attributes just want to change the image quality

Added ability to add attributes like `id` , `class`, `alt` to html() method
Uses

    Image::open('open.jpg')->html($title = 'some title', $type = 'jpg' , array('class'=>'test pull-right','id'=>'test','alt' => 'name')));
`NULL` can also be provided if don't want any attributes just want to change the image quality
public function html($title = '', $type = 'jpg', $attributes = array(), $quality = 80)
{
$html = array();
if (!empty($attributes)) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you do this test?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you don't want to set any attribute, only want to change the quality of image you can pass null and empty array or no array at all. That will just change the quality of image and no attribute are added to the output.
Eg: html('title','jpeg','',20)) or html('title','jpeg',NULL,20)) or html('title','jpeg',array(),20))

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but since the foreach loop will not have any effect in this case the test is not useful

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

foreach is not execute only when you pass the NULL , if you pass an empty array or and empty string it will executed at least one time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants