Embed Twitter pics as a collage for a website - image

I'm trying to create a collage of images that are sourced from a twitter feed to be displayed in a website banner.
So far I have set up the Twitter authentication
I'm not sure how to go about extracting just the images from her feed, or embed them in the desired manner.
Any help or information would be greatly appreciated.
Click here to view a possible outcome I'm looking for.
Thanks!

To simply dump a couple of images, try this:
<?php
require_once("/twitteroauth/twitteroauth.php");
$consumerKey = "0LQwV6gQi1hi8TPOMvfqy7qpM";
$consumerSecret = "AuShkWcg7lj8VYyKYOH6WPW8tY6B2QuB8kgRpmALVrg0VK0mM0";
$accessToken = "624631261-DjWeq4RB0eGAB2lr68skZE1zbfDcg2x6BEyJzFZO";
$accessTokenSecret = "8XnWnkiFQ803r9sHVkDrZNhD50EuJlnw8sZI2EPsA9p7X";
$connection = new TwitterOAuth($consumerKey, $consumerSecret, $accessToken, $accessTokenSecret);
$tweets = $connection->get("https://api.twitter.com/1.1/search/tweets.json?q=%rhyareegaming%20filter%3Aimages&include_entities=true");
foreach ($tweets->statuses as $status) {
?>
<img src="<?php echo $status->entities->media[0]->media_url; ?>">
<?php
}

Related

Rename a base64 encoded image on download

I have the following code to display an image - without going into details about why I am not just using the image name.
<?php
$data = base64_encode(file_get_contents('example.png'));
$info = getimagesize('example.png');
$image = sprintf('data:%s;base64,%s', $info['mime'], $data);
?>
<img src="<?php echo $image; ?>" download='final-image.png' />
It works as expected displaying the image.
However when someone right-clicks the image, in FireFox it wants to save it as (scriptname).png and Chrome wants to save it as download.png.
I can't use header() as headers are already being sent.
Is there any way to force a filename that works across browsers?

Magento Active Filters on Search Page

I want to implement active filters on my magento ecommerce site.
I have been successful in implementing it, but the issue is, the code works on only category pages and not search page
Here's the code that I'm using
<?php /*Create filter dependencies*/
$_activeFilters[] = array();
$_filters = Mage::getSingleton(‘Mage_Catalog_Block_Layer_State’)->getActiveFilters();
foreach ($_filters as $_filter):?>
<?php echo $this->stripTags($_filter->getLabel()) ?><a href=”<?php echo $_filter- >getRemoveUrl() ?>” title=”<?php echo $this->__(‘Remove This Item’) ?>”><?php echo $this->__(‘Remove This Item’) ?></a>
<?php endforeach; ?>
I'm using this code in toolbar.phtml. Any clue as in why its not working on search page. Any Solutions would be of great help.
Thanks,
Sushil
You can use this code for fetching filters on either category list page or search results page
<?php
if(Mage::registry('current_category')) {
$_filters = Mage::getSingleton('catalog/layer')->getState()->getFilters();
} else {
$_filters = Mage::getSingleton('catalogsearch/layer')->getState()->getFilters();
}
?>
I have used this code in toolbar.phtml, to show removable filters below the toolbar, like flipkart does.
The problem is with this line:
$_filters = Mage::getSingleton(‘Mage_Catalog_Block_Layer_State’)->getActiveFilters();
This gets a singleton which only contains the necessary data when on a category page.
See this question for more details: Magento - How to add Layered Navigation to Advanced Search?

Magento - All categories have same image

So there's some code floating around that gets an individual subcategory's image:
foreach ($collection as $cat){
$cur_category = Mage::getModel('catalog/category')->load($cat->getId());
$layer = Mage::getSingleton('catalog/layer');
$layer->setCurrentCategory($cur_category);
$_img = $this->getCurrentCategory()->getImageUrl();
}
Where $cat is the subcategory I'm trying to get the image of. The problem I'm running in to - the images for the subcategories are all the same! The first image from the subcategories is the image that shows up on the page. The links and names are all correct though: (this is also in the for loop)
<div>
<a href="<?php echo $helper->getCategoryUrl($cat);?>">
<img src="<?php echo $_img; ?>" title="<?php $cat->getName() ?>"/>
<cite><?php echo $cat->getName();?></cite>
</a>
</div>
I'm making this modification in catalog/category/view.phtml. There's a bit more to it than shown, but this is all the relevant information.
Edit
All categories have their own unique images, which are properly uploaded. They show in the admin correctly. Also, $cat->getId() is returning the correct id's for the individual subcategories.
#RandyHall, are your sure that $this->getCurrentCategory() will get the category from the same place as $layer->setCurrentCategory($cur_category); will set it to?
Watch the source code here and here.
As you can see category is set to the layer model and get returns category from registry(via call to block).
So I would suggest you to do something like this:
$_img = $layer->getCurrentCategory()->getImageUrl();
Perhaps you are doing wrong when getting image url.
instead of using
$_img = $this->getCurrentCategory()->getImageUrl();
try below code
$_img = $cur_category->getImageUrl();
foreach ($collection as $cat){
$cur_category = Mage::getModel('catalog/category')->load($cat->getId());
$_img = $cur_category->getImageUrl();
}
Looks to me like this is what you are going for?

Magento change backgrounds per session

I'm looking for a simple extension that allows via admin console to load some background pics and display them on the frontend per user session (not on refresh). I don't think anything is out there so some pointers on how to start building one would be great too. Thanks!
Here is a solution for you.
You can upload images through Magento admin into media storage. Lets say you created a subdir "backgrounds" in there and uploaded various images there. Then all you need to do is add the following code into app/design/frontend/[your-interface]/[your-theme]/template/page/html/header.php
<?php
if(!$background = Mage::getSingleton('core/session')->getBackground()){
$img_arr = array();
if($handle = opendir(Mage::getBaseDir('base').'/media/backgrounds/')){
while(false !== ($entry = readdir($handle))){
if(!preg_match('/^\.+$/', $entry)){
$img_arr[] = $entry;
}
}
closedir($handle);
}
if($img_cnt = count($img_arr)){
$background = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK).$img_arr[rand(0, $img_cnt-1)]
Mage::getSingleton('core/session')->setBackground($background);
}
}
?>
<?php if(isset($background) && $background) : ?>
<style> background:url(<?php echo $background; ?>); </style>
<?php endif; ?>
Did not tested it live. Let me know.

Rewriting URL's in codeigniter with url_title()?

I am rewriting my website with codeigniter and have something I want to do but not sure it is possible.
I have a gallery on my site powered by the Flickr API. Here is an example of the code I use to display the Landscape pictures:
<?php foreach ($landscapes->photoset->photo as $l->photoset->photo) : ?>
<a href="<?=$l->photoset->photo->farm?>/<?=$l->photoset->photo->server?>/<?=$l->photoset->photo->id?>/<?=$l->photoset->photo->secret?>/<?=$l->photoset->photo->title?>">
<img class="f_thumb" src="<?=$l->photoset->photo->farm?>.static.flickr.com/<?=$l->photoset->photo->server?>/<?=$l->photoset->photo->id ?>_<?=$l->photoset->photo->secret ?>_s.jpg" title="<?=$l->photoset->photo->title?>" alt="<?=$l->photoset->photo->title?>" />
</a>
<?php endforeach; ?>
As you can see when a user clicks on a picture I pass over the Farm, Server, ID, Secret and Title elements using URI segments and build the page in the controller using
$data['farm'] = $this->uri->segment(3);
$data['server'] = $this->uri->segment(4);
$data['id'] = $this->uri->segment(5);
$data['secret'] = $this->uri->segment(6);
$data['title'] = $this->uri->segment(7);
Everything works and is fine, but the URL’s are a tad long. Example:
http://localhost:8888/wip/index.php/gallery/focus/3/2682/4368875046/e8f97f61d9/Old_Mill_House_in_Donegal
Is there a way to rewrite the URL so its more like:
http://localhost:8888/wip/index.php/gallery/focus/Old_Mill_House_in_Donegal
I was looking at using:
$url_title = $this->uri->segment(7);
$url_title = url_title($url_title, 'underscore', TRUE);
But I can’t seem to be able to get it to work. Any ideas?
Are the links linking internally? Or are they linking to flickr? If it's internally, I'd suppose you could pass all the requisite information via POST. If it's to flickr, I don't think there is a way you can control how they want requests to come in for a specific item.
What's the endgame/purpose of all that extra info (secret, server, etc)?

Resources